Skip to content

Demonstrates discrepancies in validation handling between the documentation and Rails 4.2

Notifications You must be signed in to change notification settings

cdonadeo/rails_validation_test

Repository files navigation

What's This?

This is a stock Rails application designed to demonstrate a single case where validation failure handling does not match the documentation.

How To Reproduce The Issue

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.

How this app was created:

  1. mkdir rails_validation_test
  2. cd rails_validation_test
  3. echo '2.4.1' > .ruby_version
  4. echo '.gems' > .rbenv_gemsets
  5. gem install bundler rails:4.2.8
  6. rails new .
  7. Create migration in db/migrate/20170515180342_make_entities.rb
  8. Create model in app/models/group.rb
  9. Create model in app/models/thing.rb
  10. Create model in app/thing_group_memberships.rb
  11. rake db:migrate

About

Demonstrates discrepancies in validation handling between the documentation and Rails 4.2

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published