Ruby on rails 如何在接受?page=param的rails中形成rel规范url?
我尽量避免使用gem,因为我的问题很简单 我的网站有以下?参数=Ruby on rails 如何在接受?page=param的rails中形成rel规范url?,ruby-on-rails,ruby,ruby-on-rails-3,ruby-on-rails-3.1,ruby-on-rails-3.2,Ruby On Rails,Ruby,Ruby On Rails 3,Ruby On Rails 3.1,Ruby On Rails 3.2,我尽量避免使用gem,因为我的问题很简单 我的网站有以下?参数= "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 of
"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
在得到一些帮助后,我被告知?page=
是唯一真正重要的一个,因为除了分页之外,我的所有内容都可以在没有任何查询参数的情况下访问
现在我有了这个:
<link rel="canonical" href="<%= "http://#{request.host + request.fullpath}" %>">
因此,我的问题是如何修改它,使其仅放置URL,并放置?page=如果它存在,但忽略所有其他参数?这似乎是正确的
params[:page])}“%>”>
现在是2017年,我知道,你也可以使用Rails
在最简单的情况下,应该是可行的:
如果您正在使用协议或希望在规范url中使用GET参数,请不要忘记添加它
<head>
<%= auto_discovery_link_tag(:atom, your_path('your-params'), { rel: "canonical" }) %>
</head>