Kevin Hastie wrote:
> Kevin Hastie wrote:
> 
> I guess what I really want is something like this:
> 
> class Address< ActiveRecord::Base
>   belongs_to :addressable, :polymorphic => true
> end
> 
> class Business< ActiveRecord::Base
>  has_one :address, :as => :addressable
> end
> 
> class School < ActiveRecord::Base
>  has_one :address, :as => :addressable
> end
> 
> h) I don't suppose there is a way to do that with the scaffold.  Is 
> there a typical set of scaffold options that would map to this?
> 
> i) Lastly, I guess I am better off avoiding polymorphism at the 
> beginning, huh?  I should just be doing a simple mapping...

What about the polymorphic example I gave?  It seems like this is the 
best practice approach, but I am finding it VERY hard to find examples 
that I can get to work, and I feel like I see lots of complaints that 
the feature is "broken" within Rails.

Is it only for has_many relationships or can it be used like I am trying 
with has_one relationships?  Is my example the correct way to go about 
it?  If so, what else needs to happen?

(and what about questions h and i?)

j) What seems much easier is to have the Business and School tables to 
each have an address_id, and be done with it.  That's what I would have 
done days ago were I programming a language without so many "handy" 
shortcuts.  But to do so, doesn't it have to be

Address
has_one :business
has_one :school

Business
belongs_to :address

That doesn't seem right..?
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" 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/rubyonrails-talk?hl=en.

Reply via email to