开发者

Does Rails have a method to construct src="foo.php?href=http%3A%2F%2Fexample.com%2F&layout=standard"

It seems that we will need 2 methods, one is CGI.escape and the other might be h (unless we hardcode &.

Is there a method that takes an array or hash of params, and compose it into this form?

src="foo.php?href=http%3A%2F%2Fexam开发者_JS百科ple.com%2F&layout=standard"

It is for Rails 2.2.2, so if there is a method in Rails 2.x that can do it?


I believe you can use Object#to_query to do it, but I'm not certain if it is available in Rails 2.x. For example:

{
  :href => "http://example.com/",
  :layout => "standard"
}.to_query # => "layout=standard&href=http%3A%2F%2Fexample.com%2F"
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜