I want to create a drop-down list using Active Hash by executing the following command in the terminal.
%rails g model model name--skip-migration
When I created a model for Active Hash and edited each model, I got an error like this one.
I didn't install the Active Hash gem in the first place. (It's a rudimentary mistake ...)
Write Active Hash at the bottom of the Gemfile.
Gemfile
gem 'active_hash'
Bundle install and reflect in Gemfile.lock
terminal
% bundle install
Bundle complete! 19 Gemfile dependencies, 81 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
I was able to reflect it in the view.
This time I forgot to add a gem in Active Hash, but surprisingly several times in the past, even though I wanted to use the functions of other gems, I was coding without introducing gems. Sometimes caused an error.
As a future measure, it is necessary to first create an application while checking whether the description is solid in the Gemfile and which gem supports the application before proceeding with coding. I felt that.
Recommended Posts