mirror of
https://github.com/fspc/BikeShed-1.git
synced 2026-10-04 08:06:09 -04:00
Fix: user email should be null instead of empty string
This commit is contained in:
@@ -54,6 +54,11 @@ class User < ActiveRecord::Base
|
|||||||
roles.include?(role)
|
roles.include?(role)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# try keeping the email field in DB clear and consistent, without empty strings (NULLs instead)
|
||||||
|
def email=(other)
|
||||||
|
super(other.blank? ? nil : other)
|
||||||
|
end
|
||||||
|
|
||||||
### TODO methods below probably belong somewhere else
|
### TODO methods below probably belong somewhere else
|
||||||
|
|
||||||
def completed_build_bikes
|
def completed_build_bikes
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
class UserEmailCanBeNull < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
change_table :users do |t|
|
||||||
|
t.change :email, :string, default: nil, null: true
|
||||||
|
end
|
||||||
|
|
||||||
|
User.where(email: '').update_all(email: nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
change_table :users do |t|
|
||||||
|
t.change :email, :string, default: '', null: false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
+2
-2
@@ -11,7 +11,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20170118112258) do
|
ActiveRecord::Schema.define(:version => 20170131164224) do
|
||||||
|
|
||||||
create_table "bike_actions", :force => true do |t|
|
create_table "bike_actions", :force => true do |t|
|
||||||
t.string "action", :limit => 128, :null => false
|
t.string "action", :limit => 128, :null => false
|
||||||
@@ -183,7 +183,7 @@ ActiveRecord::Schema.define(:version => 20170118112258) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
create_table "users", :force => true do |t|
|
create_table "users", :force => true do |t|
|
||||||
t.string "email", :default => "", :null => false
|
t.string "email"
|
||||||
t.string "encrypted_password", :default => "", :null => false
|
t.string "encrypted_password", :default => "", :null => false
|
||||||
t.string "reset_password_token"
|
t.string "reset_password_token"
|
||||||
t.datetime "reset_password_sent_at"
|
t.datetime "reset_password_sent_at"
|
||||||
|
|||||||
Reference in New Issue
Block a user