ruby - Rails update_attributes without save? -


is there alternative update_attributes not save record?

so like:

@car = car.new(:make => 'gmc') #other processing @car.update_attributes(:model => 'sierra', :year => "2012", :looks => "super sexy, wanna make love it") #other processing @car.save 

btw, know can @car.model = 'sierra', want update them on 1 line.

i believe looking assign_attributes.

it's same update_attributes doesn't save record:

class user < activerecord::base   attr_accessible :name   attr_accessible :name, :is_admin, :as => :admin end  user = user.new user.assign_attributes({ :name => 'josh', :is_admin => true }) # raises activemodel::massassignmentsecurity::error user.assign_attributes({ :name => 'bob'}) user.name        # => "bob" user.is_admin?   # => false user.new_record? # => true 

Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -