我想有網址與參數化重寫,因爲在這裏說明一下:How do I rewrite URL's based on title?錯誤的URL與參數化
這裏是我的模型:
class Article < ActiveRecord::Base
belongs_to :category
self.per_page = 5
def to_param
"#{title.parameterize}"
end
end
而且我的鏈接:
<%= link_to(article.title, blog_article_path(article), {:class => "blog_title"}) %>
問題是,我沒有像/blog/article/"my-article-title"
一個鏈接,但我有/blog/article."my-article-title"
,這是錯誤的,而不是解釋。
你知道原因嗎?
我route.rb:
get "blog/index"
get "blog/category"
get "blog/article" (I don't use the show action of my article controller, is it the reason ?)
resources :categories
resources :articles
感謝
難道您發佈'routes.rb'文件的相關部分? – Bitterzoet 2013-03-25 14:07:51
最初的帖子已更新 – eluus 2013-03-25 14:14:05