I have odd problem:
After starting server I got this error:
undefined local variable or method `new_media_path'
To repair this i must go to routes.rb and change
resources :media
to
resource :media
and again to
resources :media
It's annoying. Any ideas to solve this?
You should try new_medium_path
because media
is plural form of medium
If you run rake routes
you will see all available routes.
You can also inform rails about the proper pluralization using the Inflector class. It handles most works fine, but non-standard pluralizations like 'media' aren't always pre-defined. To add your own, edit config/initializers/inflections.rb, and add this at the end:
ActiveSupport::Inflector.inflections do |inflect|
inflect.irregular 'medium', 'media'
end
This should let Rails handle all the plural/singular stuff - note this will affect that it thinks DB table names will be as well, so it'll expect the model to be class Medium, and the table name will be media
To turn the plural and singular to the same thing (i.e. always 'media'), use:
ActiveSupport::Inflector.inflections do |inflect|
inflect.uncountable 'media'
end
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