开发者

How to set routes.rb for ONLY controller and view object?

I have a controller called store_controller, and views for store. But the store doesn't have t开发者_JAVA百科he model, but I want to use store_path in the code. How can I add the store_path in routes.rb?


If you have only one store (without ID) then you can create only a single route (named store so you can use store_path):

map.resource :store, :only => [:show]

You can also just create a custom route:

map.store "/store", :controller => "store", :action => "show"


You can also read up a bit more here:

http://guides.rubyonrails.org/routing.html#customizing-resources

Which I poached from this related post:

How to define a custom path in rails?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜