Displaying 2 results from an estimated 2 matches for "hillenbrand".
Did you mean:
hildenbrand
2006 Feb 09
6
Can I protect access to a relationship?
Hi,
I have a class Match that looks like this (simplified)
class Match < ActiveRecord::Base
belongs_to :opp1, :class_name => "Player", :foreign_key => "opp1_id"
belongs_to :opp2, :class_name => "Player", :foreign_key => "opp2_id"
belongs_to :winner, :class_name => "Player", :foreign_key => "winner_id"
end
Can I
2006 Feb 09
3
accessing associated models in a validate method
Why can''t I access an associated model in a validate method? I have
some code that looks like the following:
Models:
class Product < ActiveRecord::Base
has_many: upcs
end
class Upc < ActiveRecord::Base
belongs_to :product
def validate
errors.add_on_blank(''upc'') unless product.new_record?
end
end
Controller:
def create
@product =