Tal*_*boy 2 ruby ruby-on-rails ruby-on-rails-3 ruby-on-rails-3.1 ruby-on-rails-3.2
由于问题的简单性,我试图避免使用gem。
我的网站具有以下?params =
"type" just filters by type. if this isnt specified they're all lumped together
"sort" sorts by date/whats hot/latest
"view" changes compact view/list view
"scroll" isnt even used yet, its for infinite scroll on or off which i havent put in yet
"reset" is a link when you click the logo (not the home link) that resets all session params to "all" and "whats hot" (the default)
"page" is the pagination which i think is the only really important one
Run Code Online (Sandbox Code Playgroud)
在获得一些帮助之后,我被告知?page=是唯一真正重要的帮助,因为我的所有内容都可以访问而无需任何查询参数(分页除外)。
所以现在我有了这个:
<link rel="canonical" href="<%= "http://#{request.host + request.fullpath}" %>">
Run Code Online (Sandbox Code Playgroud)
所以我的问题是我该如何修改它,使其仅放入URL,并在?page =(如果存在)但忽略所有其他参数的情况下放入?
这似乎歪了
<link rel="canonical" href="<%= "http://#{request.host + url_for(:page => params[:page]) }" %>">