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 :
<%= 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?
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
please let me know if this is correct.
the text_field helper, takes a syntax such as :
text_field(“post”, “title”, “size” => 20), which will build for you
the following html.
Which when received by your controller will give you a params hash as:
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/
and this explanation of params should be useful: http://
enjoy the ride koloa!
hello thank you for the explanation, i will do the reading!