Created
April 13, 2012 18:25
-
-
Save waratuman/2378948 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cd ~/src | |
$ rails new MLS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ bundle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cd mls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ rails generate model user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ mate db/migrate/20120411200952_create_users.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreateUsers < ActiveRecord::Migration | |
def change | |
create_table :users do |t| | |
t.string :name, :null => false | |
t.string :email, :null => false | |
t.string :phone | |
t.string :company | |
t.string :title | |
t.string :license_id | |
t.string :linkedin | |
t.string :twitter | |
t.string :facebook | |
t.string :web | |
t.string :password_digest, :null => false | |
t.timestamps | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ mate app/models/user.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User < ActiveRecord::Base | |
attr_accessor :password | |
attr_protected :password_digest | |
validates :name, :presence => true | |
validates :email, :presence => true, :uniqueness => true, :email => true | |
validates :password, :presence => true, :confirmation => true | |
validates :password_confirmation, :presence => { :if => :password } | |
validates :phone, :format => { :allow_nil => true, :with => /^[\(\)0-9\- \+\.]{10,20}\s*[extension\.]{0,9}\s*[0-9]{0,5}$/i } | |
def password=(pass) | |
return if pass.blank? | |
@password = pass | |
self.password_digest = BCrypt::Password.create(pass) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ mate Gemfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
gem 'rails', '3.2.3' | |
# Bundle edge Rails instead: | |
# gem 'rails', :git => 'git://github.com/rails/rails.git' | |
gem 'sqlite3' | |
gem 'bcrypt-ruby', :require => 'bcrypt' | |
gem 'email_validator' | |
# Gems used only for assets and not required | |
# in production environments by default. | |
group :assets do | |
gem 'sass-rails', '~> 3.2.3' | |
gem 'coffee-rails', '~> 3.2.1' | |
# See https://github.com/sstephenson/execjs#readme for more supported runtimes | |
# gem 'therubyracer', :platform => :ruby | |
gem 'uglifier', '>= 1.0.3' | |
end | |
gem 'jquery-rails' | |
# To use ActiveModel has_secure_password | |
# gem 'bcrypt-ruby', '~> 3.0.0' | |
# To use Jbuilder templates for JSON | |
# gem 'jbuilder' | |
# Use unicorn as the app server | |
# gem 'unicorn' | |
# Deploy with Capistrano | |
# gem 'capistrano' | |
# To use debugger | |
# gem 'ruby-debug19', :require => 'ruby-debug' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment