Hi
I have 2 models like request and contacts
Request < ActiveRecord::Base
has_many :contacts
end
Contact < ActiveRecord::Base
belongs_to :request
validates_presence_of :name, :message => 'Name should not be blank'
validates_presence_of :email, :message => 'Email should not be blank'
end
Now in RequestController
def create
@request = Request.new(params[:request])
@request.contacts << Contact.new(params[:contact])
if @request.save
-------everything ok
else
self.flash[:error] = @request.errors.each{}
render :action => "new"
end
end
But here my problem is I expected
'Name should not be blank' 'email should not be blank'
But what I got is
contacts is invalid
Why this Please help me to get the errors as I expected
Thanks in advance
Sijo
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---