rubyonrailsin

A Ruby and Rails talk

Saturday, March 20, 2010


[Rails] Calling a default record for a has_many association

by rubyonrailsin 0 comments

Tag


Share this post:
Design Float
StumbleUpon
Reddit

I have a Shop model that has_many Zones (a Zone assigns different
pricing to products). I want to save a default Zone for a Shop. This
is what I have in my Shop class:

has_one :default_zone, :class_name => "Zone"

After that, however, I am a bit lost. I know I can manually set
shop.default_zone_id to a zone.id, but I would imagine a better system
of doing this exists.

Thanks,
Angelo, a desperate man

--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment

Subscribe feeds via e-mail

Blog Archive