Rails - 何时在查询字符串中转义&符号

时间:2016-03-29 21:12:36

标签: ruby-on-rails url web query-string query-parameters

在下列情况下是否正确?

class SomeController
  def action
    yada yada
    value = CGI.escape(value)
    value2 = CGI.escape(value2)
    redirect_to "http://boogeywoogey.com?key=#{value}&key2=#{value2}"
    redirect_to "http://boogeywoogey.com?key=#{value}&key2=#{value2}"
  end
end

或者在视图中,

link_to "http://urlwithnohelper.com?key=value&key2=value2"
link_to "http://urlwithnohelper.com?key=value&key2=value2"

1 个答案:

答案 0 :(得分:0)

如果您所做的只是放置指向其他网站的链接,为什么要创建控制器操作并且必须提供不必要的请求?

相关问题