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

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -