I created a scaffold in rails called Cove. In the controller, the instance variable is automatically called @cofe. Why is this happening?

Here are the steps I took. At the command line:

rails new lcdemo rails create a scaffold Name Cove: string

(created an entry in seeds.rb)

rake db: migrate rake db: seed

In the controller and view files, instance variables are called cofe instead of cove.

+3
source share
2 answers

Cause

"cove".pluralize
=> "coves"
"coves".singularize
=> "cofe"

Decision

You can edit the config / initializers / inflections.rb file to create a custom inflection to teach Rails that the only number of bays is a bay.

inflect.irregular 'cove', 'coves'
+3
source

Inflector, . , "" "", , , "" ( "", "" ..), "Cofe".

, , config/initializers/inflections.rb, ?

inflect.plural "cove", "coves"
inflect.singular "coves", "cove"
+2

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


All Articles