如何使用太阳黑子创建 SEO 友好的 url?
我想从这个转换一个搜索:
http://localhost:3000/restaurant?utf8=&search=newyork
对于这样的事情:
http://localhost:3000/restaurant/newyork
    如何使用太阳黑子创建 SEO 友好的 url?
我想从这个转换一个搜索:
http://localhost:3000/restaurant?utf8=&search=newyork
对于这样的事情:
http://localhost:3000/restaurant/newyork
    路由器:
match '/restaurant/:q' => 'restaurants#search'
控制器:
class RestaurantsController < ApplicationController
  def search
    @search = Restaurant.search do
      keywords params[:q]
    end
    @restaurants = @search.results
  end
end
以生成该 URL 的方式提交表单更多地取决于您的设计判断。您可能需要使用一些 Javascript 来拦截默认提交操作以制作并重定向到自定义 URL。