As a Rails beginner, I have summarized the points I stumbled upon as a memorandum.
Rails engineer training course taught by full stack engineers
The following error occurred when updating the Rails version to 5.2 series with Gemfile
and starting the container.
Exiting
web_1 | /app/config/initializers/new_framework_defaults.rb:21:in `<top (required)>': undefined method `halt_callback_chains_on_return_false=' for ActiveSupport:Module (NoMethodError)
You can tell by reading the error,
It can be read that the cause is the ** halt_callback_chains_on_return_false ** method of /app/config/initializers/new_framework_defaults.rb
.
After investigating, it seems that halt_callback_chains_on_return_false has been removed from Rails 5.2, so commenting it out can solve the problem.
new_framework_defaults.rb
# Do not halt callback chains when a callback returns false. Previous versions had true.
#ActiveSupport.halt_callback_chains_on_return_false = false <=Comment out
Test with Rspec from command
docker-compose exec web bundle exec rspec ./spec/models/
Then, the following error is output (error excerpt)
rails aborted!
ActiveRecord::MismatchedForeignKey: Column `board_id` on table `board_tag_relations` has a type of `int(11)`.
This does not match column `id` on `boards`, which has type `bigint(20)`.
To resolve this issue, change the type of the `board_id` column on `board_tag_relations` to be :integer. (For example `t.integer board_id`).
Before 5.1 series, when migration is created, the id column is created with int by default, but from 5.1 series this is changed to big int. Since FK constraints cannot be set between columns with different types, it is necessary to unify the types.
As a solution, modify board_tag_relations.board_id to int type and db: migrate: reset
to solve the problem.
Error occurred in redirect_to: back
redirect_to :back, flash: {
user: user,
error_messages: user.errors.full_messages
}
From Rails 5.1 series
It has been replaced with redirect_to: back
=>redirect_back (fallback_location: root_path)
, so if you fix it, the problem will be solved.
redirect_back(fallback_location: "http://localhost",
flash: {
user: user,
error_messages: user.errors.full_messages
})
Recommended Posts