Hello,
This is my first day on rails. I''ve been trying to make a drop down
menu
work all day but no joy.
--------Controller---------
class ScenariomgrController < ApplicationController
def runscenarios
@booknames = Obsrvbl.find(:all, :order => "name").collect{ |o|
[o.name, o.id] }
end
def createipfile
render_text @booknames.id
end
end
----------View-----------
<p>Observable Name</p>
<%= select "booknames", "id", @booknames %>
<%= link_to "Run Scenario", :action =>
''createipfile''%>
-------------------------
No matter what I do, clicking the link does not show me the selected
value. I have read 20+ posts for the select statement and read the api
but cannot see why I cannot see the selected value on clicking the "run
scenario" link to activate the createipfile action.
Is it that session variables are not shared between different
subroutines?
Thank you so much!
Aman
--
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
-~----------~----~----~----~------~----~------~--~---
Aman Thind wrote:> No matter what I do, clicking the link does not show me the selected > value. I have read 20+ posts for the select statement and read the api > but cannot see why I cannot see the selected value on clicking the "run > scenario" link to activate the createipfile action.Basically, it''s because a link doesn''t submit a form. It gets a new URL from the page, in your case always /scenariomgr/createipfile . You need to create a form that posts to createipfile. The form should contain your select list element and a submit button. When that submit button is clicked, the selected value will be passed to the createipfile action, in which you can retrieve it from the params hash by doing params[:booknames][:id]. If you insist on having a link submit your form you need to fiddle with Javascript, but I''d recommend you start with the easy case, which is the above. PS: You might want to follow one or more of the tutorials from http://www.rubyonrails.org/docs to learn more about the basic stuff like passing parameters and what not. -- Jakob Skjerning - http://mentalized.net --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---