mirror of
https://github.com/heartcombo/devise.git
synced 2026-01-09 23:08:05 -05:00
Allow null to be given to authenticable.
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
class Admin < ActiveRecord::Base
|
||||
devise :all, :except => [:recoverable, :confirmable, :rememberable]
|
||||
devise :all, :except => [:recoverable, :confirmable, :rememberable, :validatable]
|
||||
end
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user