This is a stock Rails application designed to demonstrate a single case where validation failure handling does not match the documentation.
Don't forget to set up the app:
bundle install
rake db:migrate
In IRB:
Thing.create
Group.create
group = Group.first
group.update({'thing_ids' => ['1']})
The above will cause an ActiveRecord::RecordInvalid
exception to be raised when update
is called. According to the documentation, it should return false. This only occurs if the ThingGroupMembership
fails to validate; the method correctly returns false
if the Group
doesn't pass validation instead.
mkdir rails_validation_test
cd rails_validation_test
echo '2.4.1' > .ruby_version
echo '.gems' > .rbenv_gemsets
gem install bundler rails:4.2.8
rails new .
- Create migration in
db/migrate/20170515180342_make_entities.rb
- Create model in
app/models/group.rb
- Create model in
app/models/thing.rb
- Create model in
app/thing_group_memberships.rb
rake db:migrate