Puralization and singularities (kinks) for media / environment in Rails 5

I work with Rails 5 . I just created a model Mediausing the scaffold tool.

rails g scaffold media name:string

And I have different names and routes, browsing, etc.

enter image description here

This was not proper pluralization, so when I rake routes, I received unexpected routes medium, and because of this I had different problems in the views.

enter image description here

When I try to use <%= form_for @media do .., I complained about no method media_index_path.

How can I fix this and work well?

Thanks in advance for your help.

+4
source share
2 answers

, , - inflections, :

enter image description here

, , inflections :

  • .

    rails d scaffold Media
    
  • config/initializers/inflections.rb :

    ActiveSupport::Inflector.inflections(:en) do |inflect|
        # Here you can put the singular and plural form you expect
        inflect.irregular 'media', 'medias'
    end
    
  • :

    rails g scaffold Media
    

, . () Ruby on Rails.

, .

+5

: D

googled , , , media, , , Rails .

. , config/initializers/inflections.rb

ActiveSupport::Inflector.inflections(:en) do |inflect|
  inflect.uncountable %w( media )
end
+1

Source: https://habr.com/ru/post/1655142/


All Articles