update will change the state of object and database
update_attributes
ex:
rabbit.update_attributes( :name=> "peter", :age=> 13)
update
ex:
Rabbit.update( 5, :name=>"peter", :age=>13)
update rabbit with id =5
update_all:
Rabbit.update_all(:name=>"peter")
all rabbits' names become "peter"
use save:
ex:
rabbit.name="peter"
rabbit.save
use save to update database
沒有留言:
張貼留言