Created
May 14, 2010 09:32
-
-
Save fudanchii/400984 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'bcrypt' | |
module Gencore | |
class User < Sequel::Model | |
set_schema do | |
primary_key :id | |
varchar :username | |
text :passwd, :default => '*' | |
end | |
one_to_one :biodata, :class => 'Gencore::Biodata' | |
one_to_many :ftp_logs, :class => 'Gencore::Ftp_log' | |
include BCrypt | |
def password | |
@password ||= Password.new(passwd) | |
end | |
def password=(new_password) | |
@password = Password.create(new_password) | |
self.passwd = @password | |
end | |
create_table unless table_exists? | |
##### test case, TODO move this to spec file | |
if empty? | |
user = create(:username => 'fudanchii', | |
:password => 'testest') | |
puts user.password | |
puts user.password == 'testest' | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment