admin - how to deactivate and activate users from application in ruby on rails -
i implementing dashboard facility in ruby on rails application admin can enter , see users registered application. dashboard, admin can deactivate or activate users( may time of period). have user table has is_active column. know , can done setting flag on column in table. please explain in details.
following user table.
create_table "users", :force => true |t| t.string "email", :default => "", :null => false t.string "encrypted_password", :default => "", :null => false t.string "reset_password_token" t.datetime "reset_password_sent_at" t.datetime "remember_created_at" t.integer "sign_in_count", :default => 0 t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" t.string "current_sign_in_ip" t.string "last_sign_in_ip" t.boolean "is_admin" t.boolean "is_active" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false t.string "username" end
please me in implementing activation , deactivation of users application(admin can this)
you can create 2 method in user
model activating & deactivating user
class user < activerecord::base def activate_account! update_attribute :is_active, true end def deactivate_account! update_attribute :is_active, false end end
as type of is_active
column boolean, can use user.is_active?
method generated rails check if user's account active or not
Comments
Post a Comment