Rails: multiple names for a resource
Is there an elegant way of having multiple names for a single resource. We would like to give the user a choice via a setting of what they would like to call their "things". I.e. products, items, services whatever.
So far I can only think of using multiple routes to a single controller:
resources :products
resources :items, :controller => :products
resources :services, :controller => :products
The only thing I can see is the views will become q开发者_开发技巧uite complex having to ask which URL to generate based on the users setting.
Any thoughts or ideas would be appreciated!
Not sure exactly what you you're trying to do but Rails can do all of the heavy lifting for URL generation through the url_for
helper. See here
精彩评论