Kane Wu
2008-May-07 01:30 UTC
Begginer question: how to edit using options_from_collection
Hi,
I have been stuck on this problem for 2 hours and still have no idea how
to do it. Basically I have a relationship between Workout and Exercise
Exercise has many Work out
anyway in my code at Workout.view the edit.html that was generated
through scaffold I wrote this
<% form_for(@workout) do |f| %>
<p>
<b>Exercise</b><br />
<%= select_tag "exercise",
options_from_collection_for_select(Exercise.find_all, "id",
"name",
@workout.exercise_id) %>
</p>
<%= f.submit "Update" %>
</p>
<% end %>
For some reason it does not update when I click it. I don''t have any
errors but it just doesn''t update. Does anyone know why?
Any help would be apperciated. Thanks
Kane
--
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
-~----------~----~----~----~------~----~------~--~---
Kane Wu
2008-May-07 15:08 UTC
Re: Begginer question: how to edit using options_from_collec
bump -- 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 -~----------~----~----~----~------~----~------~--~---
What doesn''t update when you click on what? If I had to guess, I''d say that your workout record isn''t updating when you click on the update button because you''re using "select_tag" instead of "f.select", so your exercise information shows up in params[:exercise] instead of params[:workout][:exercise]. You''re probably saving your workout record based on params[:workout], so it''s not getting the exercise info. -Kyle On May 7, 10:08 am, Kane Wu <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> bump > -- > Posted viahttp://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 -~----------~----~----~----~------~----~------~--~---