Re: Problems with select pulldowns combined with has_many :through

Mark Reginald James
2006-09-22T14:47:06Z

mrmarkham wrote:
> I''m having problems with the above.  For description purposes,
let''s
> just assume I have 3 models:  User, Movie and Viewings, with the
> following obvious fields:
>
> users - name
> movies - name
> viewings - user_id, movie_id
>
> I''m trying to use collection_select to create the appropriate
pulldown,
> but the following isn''t working:
>
> collection_select("user", "viewings.movie_id", @movies,
"id", "name")
>
> When I run it, I''m getting the following:
>
> undefined method `viewings.movie_id'' for #<User:0x23a32b8>
>
> What am I missing?

At present, such chained method parameters in Active Record form
helpers won''t work. You have to set @viewings = @user.viewings
and call collection_select(:viewings, :movie_id, @movies, :id, :name)

--
We develop, watch us RoR, in numbers too big to ignore.


--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---