Question

My rails application requires few values to be specified in the text box. My web page contains few text boxes .How can i specify the values of these text boxes in the url as query string while using webrick?can any one help, am new to this.

Thanks in advance.

Was it helpful?

Solution

If your url looks like this: localhost:3000/Accounts/1/edit?value1=A&value2=B and you want to put those in text boxes you must create some instance variables in the controller, and then reference them in the view.

Controller Action:

def edit
   @value1 = params[:value1]
   @value2 = params[:value2]
end

View:

<%= text_box_tag :value1, @value1 %>
<%= text_box_tag :value2, @value2 %>

If you followed my example, the first text box would display A and the second B.

Note that the webserver has no effect on this behavior. webrick, apache, mongrel, thin, etc... will all do this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top