ruby - WEBrick run on hanami 1.0.0 shows errors because of wrong inflection -


i generated model hanami generate model stimulus. fixed "stimuluses" "stimuli" in migration file name , inside, table name.

everytime load page error in server console window:

[rom::relation[stimuluses]] failed infer schema. make sure tables exist before rom container set up. may happen when migration tasks load rom container, not needed migrations connection required (schema parsing returned no columns, table "stimuluses" doesn't exist)

i looked libraries , found functionality has inflecto library. tried both adding hanami project this:

# /config/initializers/inflecto.rb require 'inflecto'  inflecto.inflections |inflect|   inflect.irregular('stimulus', 'stimuli') end 

and editing defualt library file:

# gems/inflecto-0.0.2/lib/inflecto/defaults.rb inflecto.inflections |inflect|   ...   inflect.irregular('stimulus', 'stimuli')   ... end 

but message still there after restarting server.

is should solve , if yes, how this?

edit:

also tried:

# /config/initializers/inflector.rb require 'hanami/utils/inflector'  hanami::utils::inflector.inflections   exception 'stimulus', 'stimuli' end 

i'm assuming talking hanami v1.0.0, right?

you succeeded. hit initializers seem not loaded when executing hanami commands , maybe bug in code reloading. instead of initializer put file gets loaded when hanami commands executed or require initializer file in such place. e.g.,

# config/initializers/inflections.rb require 'hanami/utils/inflector'  hanami::utils::inflector.inflections   exception 'stimulus', 'stimuli' end 

and in environment file

# config/environment.rb # ... require_relative 'initializers/inflections.rb' # ... 

i'm not sure if place put custom inflection rules, @ least works.


Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -