开发者

Routing conflicing with another, /articles/article_name_here and /articles/archives

My routes has:

re开发者_如何转开发sources :articles

article_controller.rb has:

def show()
   @article = Article.find(:first, :conditions => {:title => params[:id]}) 
end

def archives()
end

Now the show() method respondes to the article_name, not the ID.

So the problem is, the url:

www.example.com/article/this-is-a-title

conflicts with:

www.example.com/article/archives

as it thinks the parameter 'archives' is a article title and maps to the show() action.

How can I fix this?


Before the resources definition make another route

match 'article/archives', :to => 'articles#archives'

Top routes take precedence over bottom routes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜