class Article < ActiveRecord::Base
has_many :comments
end
class Comment < ActiveRecord::Base
belongs_to :article
validates_presence_of :body
validates_presence_of :author_name
end
If I leave the author_name as blank then I am getting proper validation error. All good.
>> Article.first.comments.create(:body => 'dummy body').errors.full_messages
=> ["Please enter your name"]
Look at this example.
>> a = Article.first
>> a.comments.create(:body => 'dummy body')
>> a.errors.full_messages
["Comments is invalid"]
I send instance of article (a in this case) to view layer. I was wondering how do I get access to the pricise error 'please enter your name' from instance object a.