我现在已经看了一会儿,但我不确定如何最好地描述我对谷歌的请求,所以我想在这里问一下;)
在rails中,我知道当你嵌套宁静的路线时,通常会得到类似的东西:
如果你想要更有意义的东西,你可以使用slugs或friendly_id来获得类似
的东西http://localhost/categories/all-your-needs/articles/rock-out-with-this-article
(假设你有唯一的名字)。
我的问题是,如何从网址重写器中删除控制器,以便获得类似的内容:
这可能吗?
答案 0 :(得分:0)
是的。你可以使用这样的东西:
Rails 2:
map.show_article ':category/:article', :controller => "articles", :action => "show"
修改强>
确定。这里有其他REST操作的URL:
map.edit_article ':category/:article/edit', :controller => "articles", :action => "edit".
要进行更新,请将:conditions => { :method => :post }
添加到上一个。
要删除,请使用第一个:conditions => { :method => :delete }
。
对于new和create,您可以使用:
map.new_article ':category/new', :controller => "articles", :action => "new"
并使用:conditions => { :method => :post }
创建相同的内容。我希望我能够帮助你!