Allow null to be given to authenticable.

This commit is contained in:
José Valim
2009-10-22 19:26:10 -02:00
parent 56f6282c22
commit 200b269d79
4 changed files with 11 additions and 6 deletions

View File

@@ -19,10 +19,11 @@ module Devise
# Creates email, encrypted_password and password_salt.
#
def authenticable
string :email, :limit => 100, :null => false
string :encrypted_password, :limit => 40, :null => false
string :password_salt, :limit => 20, :null => false
def authenticable(options={})
null = options[:null] || false
string :email, :limit => 100, :null => null
string :encrypted_password, :limit => 40, :null => null
string :password_salt, :limit => 20, :null => null
end
# Creates confirmation_token, confirmed_at and confirmation_sent_at.

View File

@@ -93,4 +93,8 @@ class ActiveRecordTest < ActiveSupport::TestCase
test 'set a default value for pepper' do
assert_equal 'abcdef', Configurable.new.send(:pepper)
end
test 'set null fields on migrations' do
Admin.create!
end
end

View File

@@ -1,3 +1,3 @@
class Admin < ActiveRecord::Base
devise :all, :except => [:recoverable, :confirmable, :rememberable]
devise :all, :except => [:recoverable, :confirmable, :rememberable, :validatable]
end

View File

@@ -16,7 +16,7 @@ ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":me
ActiveRecord::Schema.define(:version => 1) do
[:users, :admins].each do |table|
create_table table do |t|
t.authenticable
t.authenticable :null => table == :admins
if table == :users
t.confirmable