모델 레벨에 TeacherPayslip으로 속성을 업데이트하는 코드가 있습니다.레일에서 Update_attribute가 작동하지 않습니다. 4
TeacherPayslip.rb (모델) 내가 9789. 좋아하지만 업데이트 한 후 @netsalary 쇼를 올릴 때
다음def net_salary
@teacher_id = self.id
@da = (self.basic * self.da)/100
@hra = (self.basic * self.hra)/100
@gs = @da + @hra + self.basic
@pf = (@gs * self.pf)/100
@netsalary = @gs - @pf + self.special_allowance + self.bonus
@a = TeacherPayslip.find(@teacher_id)
#raise @a.inspect
raise @a.update_attribute('net_salary',@netsalary).inspect
end
(@ a.update_attribute가) netsalary @ ('net_salary'net_salary가 진정한 가치를 보여줍니다. 대신 9789.
'update_attribute' 방법은 참 또는 거짓뿐만 아니라 값 자체를 반환합니다. 그게 사법인가? – tihom
값이 – user2310209