On Thu, Jan 19, 2012 at 3:24 PM, Erwin <[email protected]> wrote:

> I have  Admin class & User class and a polymorphic Profile class
>
> class Admin < ActiveRecord::Base
>  include ActiveModel::Validations
>  has_one :profile, :as => :profitable
>  accepts_nested_attributes_for :profile
>  validates_associated :profile
>
> class User < ActiveRecord::Base
>  include ActiveModel::Validations
>  has_one :profile, :as => :profitable
>
> class Profile < ActiveRecord::Base
>  belongs_to :profilable, :polymorphic => true
>  validates :title, :first_name, :last_name , :presence => true, :if
> =>Proc.new { |p| p[:profilable_type] == "Admin" }
>
> I am trying to validates a new Admin form with nested attributes
>  but I  don't need the profile validation for the User class,
>  I wrote a validation in the Profile class  with a Proc block to test
> the profilable_type, but it's not working ....
> is there another way to try ?
>


Maybe(??) there is a mix-up between "profitable" and "profilable",
or is that intentional?

HTH,

Peter

-- 
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.

Reply via email to