0

I feel a bit stupid but this is not working (and I expected it should work):

class MembershipCard < ActiveRecord::Base
  belongs_to :association
  belongs_to :personal_record

  validates :number, :presence => true

  def dis
    print "---------------------------- #{personal_record.as_json}---------------------"
    number
  end

  def value
    id
  end
end

class PersonalRecord < ActiveRecord::Base
  has_many :membership_card, :dependent => :nullify

  def dis
    "#{name} #{surname}"
  end

  def val
    id
  end
end

print "---------------------------- #{personal_record.as_json}---------------------"

It's not printing. Any suggestion about why this is happening?

I can't access any associated model in this way and it's a disaster, basically I can't use activerecord.

4

1 回答 1

1

I solved the problem by myself: it seems that association is used inside rails (damn me), expecially this was crashing my application. Commenting it solved the issue, so I'm going to rename models/controllers and so on.

于 2012-06-28T23:05:58.280 回答