Multiple model validation

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 i’m calling the url
http:/localhost:3000/inquiries/new?type=desiner
Here i’ll get the validation of inquiry and contact.

When i’m 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 don’t 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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs