activerecord - how to update attributes in self model rails -
how update self model in rails?
class billsubtotal < activerecord::base def self.total self.update_attributes(:total => 150) end end
i want update value in model billsubtotal self model?
depends on you're wanting how you'd go this.
rails automatically creates getter/setter methods database columns, don't have create functionality explicitly, , can set method so:
class billsubtotal < activerecord::base def update_total self.total = 150 end end
or if you're working instance of class directly:
bill_subtotal_instance.total = 150
Comments
Post a Comment