On 13 November 2012 17:30, RVince <rvinc...@hotmail.com> wrote:
>
>
> On Tuesday, November 13, 2012 12:16:15 PM UTC-5, Colin Law wrote:
>>
>> You know that if you have
>> an event then its eventfeatures are event.eventfeatures and if you
>> have an eventfeature then its event is eventfeature.event?
>>
>
> Ah, it's coming back to me now, yes, you've put me on the right track. But
> in my EventfeaturesConroller, how do I access the Event that the
> Eventfeature belongs to?
>
> class Admin::EventfeaturesController < Admin::AdminController
>   def index
>     @eventfeatures = Eventfeature.all(:order => ["feature_type,sort_order"])
>   end
>
> I want @eventfeatures to be only those eventfeatures that belong to the
> given event -- how do you specify that (or is it implied by the Eventfeature
> model wherein I say it belongs_to :event) ?

How do you know (in the controller) which event you are referring to?
Are you passing it in the url?  If you pass the event id in the url
then you can fetch the event from the database and then its
eventfeatures are @event.eventfeatures.

Can I suggest that it might be worth your while working right through
a rails tutorial such as railstutorial.org (which is free to use
online) then you will get a working knowledge of the basics of Rails.

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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to