DNB5brims
DNB5brims

Reputation: 30598

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 the model, but I want to use store_path in the code. How can I add the store_path in routes.rb?

Upvotes: 3

Views: 2168

Answers (2)

ajhit406
ajhit406

Reputation: 1405

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?

Upvotes: 0

Tomas Markauskas
Tomas Markauskas

Reputation: 11596

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"

Upvotes: 5

Related Questions