Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Setup
- Rails 3.0.0
- Ruby 1.9.2
- Mysql
- #Model
- class User < ActiveRecord::Base
- # Include default devise modules. Others available are:
- # :token_authenticatable, :confirmable, :lockable and :timeoutable
- devise :database_authenticatable, :registerable,
- :recoverable, :rememberable, :trackable, :validatable
- # Setup accessible (or protected) attributes for your model
- attr_accessible :email, :password, :password_confirmation, :remember_me
- has_many :sites
- def admin?
- return self.is_admin
- end
- end
- #Schema
- create_table "users", :force => true do |t|
- t.string "email", :default => "", :null => false
- t.string "encrypted_password", :limit => 128, :default => "", :null => false
- t.string "password_salt", :default => "", :null => false
- t.string "reset_password_token"
- t.string "remember_token"
- 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.datetime "created_at"
- t.datetime "updated_at"
- t.boolean "is_admin", :default => false, :null => false
- end
- #Controller
- #Use
- irb(main):001:0> user = User.create(:email => "test@test.com", :password => "testtest", :password_confirmation => "testtest", :is_admin => true)
- => #<User id: 1, email: "test@test.com", encrypted_password: "$2a$10$69uG7Q57UWwfyR.dMbt9.ed.JfFzTLScqqv6C1UG8Epn...", password_salt: "$2a$10$69uG7Q57UWwfyR.dMbt9.e", reset_password_token: nil, remember_token: nil, remember_created_at: nil, sign_in_count: 0, current_sign_in_at: nil, last_sign_in_at: nil, current_sign_in_ip: nil, last_sign_in_ip: nil, created_at: "2010-10-16 00:57:44", updated_at: "2010-10-16 00:57:44", is_admin: false>
Add Comment
Please, Sign In to add comment