views:

46

answers:

2

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?

+4  A: 

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"
Tomas Markauskas
I get this error.undefined local variable or method `store_path' for #<StoreController:0x1032a00b8>
Ted Wong
Have you restarted your server?
Tomas Markauskas
I see, restarted, and fixed. Thank you.
Ted Wong
As a rule of thumb, if you edit any files in the config folder, you normally need to restart the server as even in the development environment it will cache all the files.
Tomas Markauskas
A: 

You can also read up a bit more here:

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

Which I poached from this related post:

http://stackoverflow.com/questions/1436309/how-to-define-a-custom-path-in-rails

ajhit406