Re: [Rails] updating attributes in active record - simple q I think!
On 4 December 2010 16:35, Michael Baldock <lists@ruby-forum.com> wrote:
> Hi all,
>
> I have a model Events, with the attributes relating to events, event
> name / band / date etc, and venue.
>
> I also have a model called venue, and all the different saved venues are
> presented as a dropdown list when creating a new event.
>
> Attributes associated with the saved venue such as latitude and
> longitude are then copied over to the event being saved. This works
> fine.
Why are you not just saying event belongs_to venue (venue has_many
events)? Then you do not need to save the venue lat and long in the
event as they will be automatically available as event.venue.latitude
for example. If you do not know how to do this have a look at the
Rails Guide on ActiveRecord relationships.
Colin
--
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.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home