Last active
December 17, 2015 00:09
-
-
Save mclosson/5518414 to your computer and use it in GitHub Desktop.
Example double error output for https://github.com/rails/rails/issues/10336
This file contains hidden or 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
class Guaranty < ActiveRecord::Base | |
belongs_to :product | |
accepts_nested_attributes_for :product | |
validates :name, presence: true | |
end |
This file contains hidden or 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
class Product < ActiveRecord::Base | |
has_many :guaranties | |
accepts_nested_attributes_for :guaranties | |
validates :name, presence: true | |
end |
This file contains hidden or 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 new issue10336 | |
$ cd issue10336 | |
$ rails g model guaranty name:string product_id:integer | |
$ rails g model product name:string | |
$ rake db:migrate | |
$ rails console | |
Loading development environment (Rails 4.0.0.rc1) | |
1.9.3-p194 :001 > g = Guaranty.new | |
=> #<Guaranty id: nil, name: nil, product_id: nil, created_at: nil, updated_at: nil> | |
1.9.3-p194 :002 > p = Product.new | |
=> #<Product id: nil, name: nil, created_at: nil, updated_at: nil> | |
1.9.3-p194 :003 > p.guaranties << g | |
=> #<ActiveRecord::Associations::CollectionProxy [#<Guaranty id: nil, name: nil, | |
product_id: nil, created_at: nil, updated_at: nil>]> | |
1.9.3-p194 :006 > g.product = p | |
=> #<Product id: nil, name: nil, created_at: nil, updated_at: nil> | |
1.9.3-p194 :007 > p.valid? | |
=> false | |
1.9.3-p194 :008 > p.errors.full_messages | |
=> ["Name can't be blank", "Name can't be blank", | |
"Guaranties product name can't be blank", "Guaranties name can't be blank"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment