Passing text from an rhtml input to a controller


I would like to allow people to type some text into a webpage and
then have that text passed to the controller (e.g. for use by a search
routine). The following code has an input box in a form. What would I
put in the “title” parameter to have that passed to the controller?
When I put in a constant string it works but when I put in things like
searcher.search_title.value or document.searcher.search_title.value the
error text complains about the first word I use. What would go where
the ??? is?

<%= link_to "search", :action => "list", :title => ???? %>

I have the “Agile Development” and “Pragmatic Programmer” books but have
read less than half of each. Much more to learn, but the above problem
may be an HTML one.


if I understand right, you want to capture a value dynamically from the
DOM yes?
what do you actually need to do?

From what I can see, you will already be passing the search_title back to the form from the . you can access this value in the controller using @params[:search_title], but you haven’t yet set a form action.

The values you specified as not working are DOM elements, and as such
will only have any meaning or value after the template has been served
and rendered by the browser. In which case you should use one of the
javascript helper functions(like observe_field or observe_form).

check the API docs for help with these: