我正在建立最后一分钟的假期网站。
现在我正忙着构建seo友好的网址。每个最后的分钟有一个国家和一个城市。我想让网址的样子的方法是TE如下:
对于页面,每个国家都最后几分钟:
“domain.com/last-minutes-spain”
对于所有页面每个城市的最后几分钟时间:
“domain.com/last-minutes-spain/barcelona”
页面的每个国家/ 。
我的路线(我使用的是friendly_id宝石):
在轨道搜索引擎优化友好的网址
match '/last-minutes-:id' => 'countries#show', :as => 'show_country'
match "/last-minutes-:country_id/:id" => 'city#show', :as => 'show_city'
countries_controller.rb:
def show
@country = Country.find(params[:id])
end
国家/ show.html.erb:
<% @country.cities.each do |c| -%>
<%= link_to(c.title, show_city_path(c.slug)) %><br />
<% end -%>
c.slug用于friendly_id宝石
展示城市路径(每个城市最后一分钟为单位)显示如下:
“domain.com/last-minutes-barcelona/spain“
所以城市和乡村都去错了地方。有谁知道如何正确地使用它?
您需要提供您遇到问题的'link_to'或'url_for'代码。 – deefour 2012-08-18 18:07:18
<%= link_to(c.title,show_city_path(c.slug))%> – 2012-08-19 08:39:07
什么是'c'?什么'c.slug'?如果您提供的信息非常有限,我们无法真正帮助您。 – deefour 2012-08-19 11:38:22