how to update attributes in self model rails
问题 how to 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 from self model? 回答1: Depends on what you're wanting to do as how you'd go about this. Rails automatically creates the getter/setter methods for database columns, so you don't have to create that functionality explicitly, and can just set the method like so: class BillSubTotal < ActiveRecord::Base def update_total