Hi All,
For multiple model validation i have done these steps.
inquiry model:
class Inquiry < ActiveRecord::Base
has_one :request
belongs_to :contact
belongs_to :company
belongs_to :inquirer, :polymorphic=>true
validates_associated :contact, :company
validates_presence_of :affiliation
end
contact model:
class Contact < ActiveRecord::Base
has_and_belongs_to_many :companies
has_one :inquiry, :as => :inquirer
validates_presence_of :first_name, :last_name, :phone_number
validates_numericality_of :country_code, :only_integer =>true
validates_length_of :country_code, :maximum=>5, :message => should not
be more than 5 digits
validates_format_of :email,:with =>
/([@s]+)@((?:[-a-z0-9]+.)+[a-z]{2,})$/i
end
This is working well with when im calling the url
http:/localhost:3000/inquiries/new?type=desiner
Here ill get the validation of inquiry and contact.
When im calling the url http:/localhost:3000/inquiries/new?type=scout
It will take only inquiry validation. It will not take contact
validation.
Here is one problem for both types, if in inquiry model if i dont have
any filed for validation then contact validation error messages will not
display. In inquiry there is no such field that i can call for
validation. So what can i do here.
Please suggest me here
--
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---