I am new to Ruby and Rails and I did following code
class Department
end
class Employee
field :depaertment_id, :default => nil
belongs_to :department, :autosave => false
def department
dept = self.super.department # check whether associated department object exists as per self.department active record's method
if dept.nil?
#other operation
end
end
end
Here from department method
I need get department object
If I do following code then department object is easily available as per rails association
class Employee
field :depaertment_id, :default => nil
belongs_to :department, :autosave => false
def get_department
dept = self.department
if dept.nil?
#other operation
end
end
end
Please help me, How can i get department object Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire