authentication - Display last logged in details using Devise in Rails 3 -
i have rails 3 application , it's using devise authentication.
i display date , time each user last logged in within administration table of users.
i have based application on following application:
https://github.com/dannymcc/rails3-base   i have read through devise github wiki , notice mentions user events trackable, can't find information regarding accessing information etc.
any help/advice appreciated!
thanks,
danny
the devise documentation outlines trackable module want.  in user model, include :trackable module so:
  devise :database_authenticatable,        ...       :trackable   and make sure database has right fields. not sure how if have user table, adding fields right names , types should trick. migration create users table looks so:
class createusers < activerecord::migration   def self.up     create_table :users |t|       t.string :name       t.string :email        t.database_authenticatable :null => false       t.recoverable       t.rememberable       t.trackable        t.timestamps     end   end    def self.down     drop_table :users   end end   the t.trackable add correct fields.  in user model, they're follows:
sign_in_count: integer,  current_sign_in_at: timestamp,  last_sign_in_at: timestamp,  current_sign_in_ip: string,  last_sign_in_ip: string   then can user.last_sign_in_at , check strftime documentation on how output time in format want.
Comments
Post a Comment