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
2010-01-23 15:43:40
I get this error.undefined local variable or method `store_path' for #<StoreController:0x1032a00b8>
Ted Wong
2010-01-23 15:47:21
Have you restarted your server?
Tomas Markauskas
2010-01-23 15:50:49
I see, restarted, and fixed. Thank you.
Ted Wong
2010-01-23 15:55:17
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
2010-01-23 15:59:29
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
2010-01-23 15:50:20