On Feb 26, 2010, at 5:38 PM, Ivan wrote:
Hi,
I'm trying Hobo for the first time, so maybe I'm missing something,
but it seems polymorphic associations aren't working properly. Steps
to reproduce:
hobo poly
cd poly
script/generate hobo_model_resource address street:string
script/generate hobo_model_resource person name:string
Add "belongs_to :addressable, :polymorphic => true" to address model
Add "has_many :addresses, :as => :addressable" to person model
When runing the server and upon trying to create an address, the
following error is thrown:
NoMethodError in AddressesController#new
undefined method `view_hints' for ActiveRecord::Base:Class
Trace: http://pastie.org/844950
You appear to have tripped on a bug - the select-one tag that's
generated for the 'addressable' association is failing to correctly
locate the model name. In this case, select-one isn't going to work
anyways, as it next tries to load the possible options. In this case,
that'd be pretty tough given that there's no (easy) way to grab all
the classes that declare the corresponding has_many.
There's lots of ways to get the offending input to not be generated,
but probably the quickest would be to add:
never_show :addressable
to your Address model. This will skip all the various view bits that
aren't terribly compatible with polymorphic associations.
Of course, that only makes sense if you're planning on mostly creating
addresses via an input-many on the various 'addressable' pages - a
strategy I'd recommend.
--Matt Jones
--
You received this message because you are subscribed to the Google Groups "Hobo
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/hobousers?hl=en.