开发者

how to write query string for webrick?

My rails application requires few values to be specified in the text box. My web page contains few text boxes .How can i s开发者_如何学Gopecify 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜