im confused. all i want is data from a form to be accessible in my controller after the user presses a buton.. in my layout view : <%= start_form_tag(:action=>''search'')%> <%= text_field(''something1'', ''something2'', :size => 25)%> <%= submit_tag "Search"%> now in my controller how do i access the field in the text box? from my reading, the first parameter is the object, second is the method, third are the options. how do i make it so i dont need a method, i just want the string in the text box? -- 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 -~----------~----~----~----~------~----~------~--~---
ok so <%= text_field(''search1'', '''', :size => 25)%> ok, so search1 is the name of the symbol that i use in params[:search1], and the second parameter is just what i want for a default value for search1 right? please let me know if this is correct. thanks. -- 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 -~----------~----~----~----~------~----~------~--~---
Koloa, the text_field helper, takes a syntax such as : text_field("post", "title", "size" => 20), which will build for you the following html. <input type="text" id="post_title" name="post[title]" size="20" value="#{@post.title}" /> Which when received by your controller will give you a params hash as: params[:post][:title] sending the above prams to a Post model, p = Post.new(params[:post]) will initialize the title method of p(a Post instantiation) with the value typed in the html form. You should read about helpers here: http://api.rubyonrails.com/ classes/ActionView/Helpers/FormHelper.html#M000389 and this explanation of params should be useful: http:// wiki.rubyonrails.org/rails/pages/UnderstandingRequestParameters enjoy the ride koloa! Jodi On 28-Oct-06, at 3:56 PM, koloa wrote:> > > > ok so <%= text_field(''search1'', '''', :size => 25)%> > > ok, so search1 is the name of the symbol that i use in params > [:search1], > and the second parameter is just what i want for a default value for > search1 right? > > please let me know if this is correct. > > thanks. > > -- > 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 -~----------~----~----~----~------~----~------~--~---
hello thank you for the explanation, i will do the reading! -- 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 -~----------~----~----~----~------~----~------~--~---