I have two models:Task and Context
Task belongs_to Context
Context has_many Tasks
In my form partial for editing a task, I want to have a drop down with all
of the contexts where you can select one for the task.
I tried:
<b>Contexts:</b><%= collection_select("task",
"context" , @contexts, "id",
"fullName", {}) %>
which doesn''t work for setting with the current value.
Any suggestions?
Thanks in advance,
Alan
--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---
Try changing the "id" param name in the collection_select method to "context_id", or whatever the name of the foreign key is within task model. Let me know if that works. -- 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 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?hl=en -~----------~----~----~----~------~----~------~--~---
Close. The solution I got to work was:
<b>Contexts:</b><%collection_select("task",
"context_id" , @contexts, "id", "fullName", {})
%>
Thanks for your help!!
--Alan
On Jan 30, 2008 12:30 AM, Chris Olsen
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:
>
> Try changing the "id" param name in the collection_select method
to
> "context_id", or whatever the name of the foreign key is within
task
> model.
>
> Let me know if that works.
> --
> 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
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?hl=en
-~----------~----~----~----~------~----~------~--~---