开发者

How can I make search result to be in a shortened url?

开发者 https://www.devze.com 2023-03-10 06:57 出处:网络
Rails guides show the following example as a generic search form. <%= form_tag(search_path, :method => \"get\") do %>

Rails guides show the following example as a generic search form.

<%= form_tag(search_path, :method => "get") do %>
  <%= label_tag(:q, "Search for:") %>
  <%= text_field_tag(:q) %>
  <%= submit_tag("Search") %>
<% end %>

Things work fine but, if I want to find something that has "251", the resulting url from the above looks like

app.com/searches?utf8=✓&keywords=251

How should I modify the code such that the re开发者_Python百科sulting url will look something like

app.com/searches/251


How about redirecting from the search action if the param[:keywords] exists like this:

redirect_to( :action => "searches", :id => params[:keywords] ) and return

Depending on how your routes are setup.

0

精彩评论

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