Hi All,
Anybody did the model validation for polymorphic association table??
class Request < ActiveRecord::Base belongs_to :user belongs_to :user_request,:polymorphic=>true belongs_to :service end
class WaterBill < ActiveRecord::Base has_one :request,:as=>:user_request,:dependent=>:destroy
validates_presence_of(:name_of_legalperson, :message => "Should not be blank")
end
Here validation in WaterBill model is not working..
my controller code...
def save @requests=Request.new() @requests.user_request=WaterBill.new(params[:water_bill]) if @requests.save flash[:notice] = 'Water Bill Was Successfully Created.' redirect_to :action => 'newwaterbill' else render :action => 'newwaterbill' end end
Any thing wrong in this code .. please clarify my doubts...