Device users
This commit is contained in:
parent
d27aff0509
commit
d3fd18a700
|
@ -0,0 +1,6 @@
|
||||||
|
class User < ActiveRecord::Base
|
||||||
|
devise :database_authenticatable,
|
||||||
|
:recoverable, :rememberable, :validatable
|
||||||
|
|
||||||
|
attr_accessible :email, :password, :password_confirmation, :remember_me, :name
|
||||||
|
end
|
|
@ -1,3 +1,5 @@
|
||||||
Rosa::Application.routes.draw do
|
Rosa::Application.routes.draw do
|
||||||
|
devise_for :users
|
||||||
|
|
||||||
root :to => "platforms#index"
|
root :to => "platforms#index"
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
class DeviseCreateUsers < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
create_table(:users) do |t|
|
||||||
|
t.string :name
|
||||||
|
t.database_authenticatable :null => false
|
||||||
|
t.recoverable
|
||||||
|
t.rememberable
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index :users, :email, :unique => true
|
||||||
|
add_index :users, :reset_password_token, :unique => true
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
drop_table :users
|
||||||
|
end
|
||||||
|
end
|
17
db/schema.rb
17
db/schema.rb
|
@ -10,6 +10,21 @@
|
||||||
#
|
#
|
||||||
# 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 => 0) do
|
ActiveRecord::Schema.define(:version => 20110309144736) do
|
||||||
|
|
||||||
|
create_table "users", :force => true do |t|
|
||||||
|
t.string "name"
|
||||||
|
t.string "email", :default => "", :null => false
|
||||||
|
t.string "encrypted_password", :limit => 128, :default => "", :null => false
|
||||||
|
t.string "password_salt", :default => "", :null => false
|
||||||
|
t.string "reset_password_token"
|
||||||
|
t.string "remember_token"
|
||||||
|
t.datetime "remember_created_at"
|
||||||
|
t.datetime "created_at"
|
||||||
|
t.datetime "updated_at"
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index "users", ["email"], :name => "index_users_on_email", :unique => true
|
||||||
|
add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
24
db/seeds.rb
24
db/seeds.rb
|
@ -1,7 +1,17 @@
|
||||||
# This file should contain all the record creation needed to seed the database with its default values.
|
require 'digest/md5'
|
||||||
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
|
|
||||||
#
|
TEST_USERS =
|
||||||
# Examples:
|
[
|
||||||
#
|
['yaroslav@markin.net' , 'Yaroslav Markin'] ,
|
||||||
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
|
['timothy.tsvetkov@gmail.com' , 'Timothy Tsvetkov'] ,
|
||||||
# Mayor.create(:name => 'Daley', :city => cities.first)
|
['alexey.nayden@gmail.com' , 'Alexey Nayden']
|
||||||
|
]
|
||||||
|
|
||||||
|
TEST_USERS.each do |tuser|
|
||||||
|
email = tuser[0]
|
||||||
|
next if User.find_by_email(email)
|
||||||
|
name = tuser[1]
|
||||||
|
pass = Digest::MD5.hexdigest(name)[0..6]
|
||||||
|
User.create! :name => name, :email => email, :password => pass, :password_confirmation => pass
|
||||||
|
puts "Created user #{name} (#{email}) and password #{pass}"
|
||||||
|
end
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe User do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
Loading…
Reference in New Issue