SL_User
SL_User

Reputation: 1954

How to update particular field value on controller method ?

I have user model as follows

t.string   "name"
t.string   "email"
t.datetime "created_at"
t.datetime "updated_at"
t.string   "encrypted_password"
t.string   "salt"
t.string   "remember_token"
t.boolean  "admin"
t.boolean  "active"

I need to change the boolean value on active attribute. How can I do it on my method ?

Upvotes: 2

Views: 6253

Answers (1)

davidb
davidb

Reputation: 8954

You can do it this way

@user.active = true
@user.save

Or this way (on update actions)

@user.update_attributes(params[:user])

Or did you mean sth else?

Upvotes: 7

Related Questions