开发者

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

开发者 https://www.devze.com 2022-12-17 17:32 出处:网络
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 route

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

精彩评论

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

关注公众号