如何在 URL 中放置搜索参数?

发布于 2024-09-03 11:09:33 字数 194 浏览 10 评论 0原文

如何获取表单来提交 url 中的参数,以便呈现的页面将包含查询(rails 2.3)?

像这样的事情:

example.com/search?name=john&age=25&city=atlanta

简单,我知道,但我不知道该怎么做......:)

谢谢。

How do I get a form to submit it's params in the url, such that the rendered page will contain the query (rails 2.3)?

Something like this:

example.com/search?name=john&age=25&city=atlanta

Simple, I know, but I'm not sure how to do it... :)

thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

始终不够 2024-09-10 11:09:33

这不是 Rails 特有的。只需将表单的 method 属性设置为 GET 即可。

This is not specific to Rails. Just set the method attribute of the form to GET.

你与清晨阳光 2024-09-10 11:09:33

正如吉米所说:确保您的表单标签如下所示:

<form method="get" .....>

as stated by Jimmy: make sure your form-tag looks like this:

<form method="get" .....>
握住你手 2024-09-10 11:09:33

如果您使用路由助手来执行此操作,请使用:

search_path(:name => "John", :age => 25, :city => "atlanta")

If you're using routing helpers to do this use:

search_path(:name => "John", :age => 25, :city => "atlanta")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文