Created
May 6, 2019 11:08
-
-
Save MittalPatel-BTC/fbba3910a31e7494d909fd9ca4b0fcab to your computer and use it in GitHub Desktop.
Rails 6 added changes for slice! method to ActiveModel::Errors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rails 6 | |
> user = User.new | |
=> #<User id: nil, name: nil, email: nil, rating: 0, password: nil, created_at: nil, updated_at: nil> | |
> user.valid? | |
=> false | |
> user.errors | |
=> #<ActiveModel::Errors:0x00007fc46700df10 @base=##<User id: nil, name: nil, email: nil, rating: 0, password: nil, created_at: nil, updated_at: nil>, @messages={:email=>["can't be blank"], :password=>["can't be blank"]}, @details={:email=>[{:error=>:blank}], :password=>[{:error=>:blank}]}> | |
> user.errors.slice!(:email) | |
=> {:password=>["can't be blank"]} | |
> user.errors | |
=> #<ActiveModel::Errors:0x00007fc46700df10 @base=##<User id: nil, name: nil, email: nil, rating: 0, password: nil, created_at: nil, updated_at: nil>, @messages={:email=>["can't be blank"]}, @details={:email=>[{:error=>:blank}]}> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment