How is it possible to use hyphen in resources urls?
For example: /my-model/
or /my-model/1
.
If I define route as resources :"my-model"
I get syntax error because rails generates method def hash_for_my-models_url(options = nil)
.
I have found the solution:
resources "my-models", :as => :my_models, :controller => :my_models
UPDATE:
As Timo Saloranta said in comment it works without :controller => :my_models
in latest Rails 3 versions.
You can use the :as
option to configure resourceful routes with hyphenated URLs:
map.resources :my_model, :as => "my-model"
results in
my_model_index GET /my-model(.:format) {:action=>"index",
:controller=>"my_model"}
...etc...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With