We are updating from Rails3 to Rails5.
At that time, an error occurred in the method called human_name, and I couldn't find the cause even if I examined it.
The method for generating validation messages in Rails3 is defined as follows:
def validation_message (object) if object.errors.count == 1 t ('activerecord.errors.template.header.one',: model =>object.class.human_name) + ":" else t ('activerecord.errors.template.header.other',: model =>object.class.human_name,: count =>object.errors.count) + ":" end end
If i move this code to Rails5
undefined method `human_name 'for #<Class: 0x00007f0d25b4c420>
It will become.
human_namehas been deprecated, but no alternative was found. https://apidock.com/rails/ActiveRecord/Base/human_name/class#996-Use-ModelClass-model-name-human
If i point out that there is an alternative or the implementation is wrong, please let me know.
Answer # 1
If you look into it, human_name is deprecated, but no alternative is found.
In the link immediately after, there is an alternative
- ruby on rails 5 - the routing that i should have set in rails5 resources is not working
- ruby - the error in rails g migration cannot be resolved
- ruby - the last db setting doesn't work when deploying rails app on aws
- bootstrap display in ruby on rails is broken
- ruby on rails 5 - actioncontroller :: invalidauthenticitytoken cannot be resolved
- ruby on rails - error in controller when transitioning with rails6 destory action
- ruby on rails - access fails after seed after deploying to heroku
- ruby on rails runtime error cannot be resolved
- ruby on rails - missing required keys: i'm having trouble resolving the [: id] error
- ruby on rails 5 - some items are not saved in db when posting from rails form
- ruby - [rails] i can't install the add favorite button
- i want to set the primary key to any column ruby migration file
- ruby on rails - dealing with wrong number of arguments (given 1, expected 2)
- ruby on rails - seed fails on heroku
- ruby on rails - cannot pass id to destroy action of intermediate table
- ruby on rails - how to manage prefectures in rails web applications
- ruby on rails - i want to post an image by dragging and dropping
- ruby - efficient writing of rails routing and actions
- ruby on rails - launching unicorn doesn't work
- ruby on rails - error in $bundle exec puma