parent
71d2066131
commit
02aa938fe4
@ -0,0 +1,8 @@
|
||||
class CnmoocUser < UserSource
|
||||
|
||||
private
|
||||
|
||||
def email_prefix
|
||||
'cnmooc_'
|
||||
end
|
||||
end
|
@ -0,0 +1,21 @@
|
||||
class UserSource < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
|
||||
def generate_email
|
||||
email = rand_email
|
||||
while User.exists?(mail: email) do
|
||||
email = rand_email
|
||||
end
|
||||
email
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def rand_email
|
||||
email_prefix + Random.rand.to_s[2..8] + '@educoder.com'
|
||||
end
|
||||
|
||||
def email_prefix
|
||||
''
|
||||
end
|
||||
end
|
@ -0,0 +1,15 @@
|
||||
class CreateUserSources < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :user_sources do |t|
|
||||
t.string :type
|
||||
t.integer :user_id
|
||||
t.string :uuid
|
||||
t.string :name
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :user_sources, [:type, :uuid], unique: true
|
||||
add_index :user_sources, :user_id
|
||||
end
|
||||
end
|
Loading…
Reference in new issue