wristband 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.DS_Store +0 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +88 -0
- data/README.md +113 -0
- data/Rakefile +21 -0
- data/VERSION +1 -0
- data/app/controllers/application_controller.rb +10 -0
- data/app/controllers/sessions_controller.rb +34 -0
- data/app/controllers/users_controller.rb +34 -0
- data/app/mailers/user_mailer.rb +33 -0
- data/app/models/session_user.rb +59 -0
- data/app/models/user.rb +52 -0
- data/app/views/layouts/application.html.erb +14 -0
- data/app/views/sessions/new.html.haml +15 -0
- data/app/views/user_mailer/email_verification.text.html.rhtml +7 -0
- data/app/views/user_mailer/email_verification.text.plain.rhtml +9 -0
- data/app/views/user_mailer/forgot_password.text.html.rhtml +10 -0
- data/app/views/user_mailer/forgot_password.text.plain.rhtml +10 -0
- data/app/views/users/show.html.haml +6 -0
- data/config/application.rb +15 -0
- data/config/boot.rb +13 -0
- data/config/database.yml +16 -0
- data/config/environment.rb +5 -0
- data/config/environments/development.rb +26 -0
- data/config/environments/production.rb +49 -0
- data/config/environments/test.rb +35 -0
- data/config/initializers/wristband.rb +1 -0
- data/config/locales/en.yml +5 -0
- data/config/routes.rb +11 -0
- data/config.ru +4 -0
- data/db/migrate/01_create_users_table.rb +26 -0
- data/db/schema.rb +27 -0
- data/lib/generators/wristband/.DS_Store +0 -0
- data/lib/generators/wristband/wristband_generator.rb +56 -0
- data/lib/wristband/application_extensions.rb +67 -0
- data/lib/wristband/authority_check.rb +160 -0
- data/lib/wristband/support.rb +28 -0
- data/lib/wristband/user_extensions.rb +89 -0
- data/lib/wristband.rb +86 -0
- data/public/robots.txt +5 -0
- data/script/rails +6 -0
- data/test/dummy/user.rb +13 -0
- data/test/test_helper.rb +78 -0
- data/test/unit/has_authorities_test.rb +86 -0
- data/test/unit/session_user_test.rb +8 -0
- data/test/unit/user_test.rb +105 -0
- data/wristband.gemspec +107 -0
- metadata +209 -0
data/.DS_Store
ADDED
Binary file
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
abstract (1.0.0)
|
5
|
+
actionmailer (3.0.3)
|
6
|
+
actionpack (= 3.0.3)
|
7
|
+
mail (~> 2.2.9)
|
8
|
+
actionpack (3.0.3)
|
9
|
+
activemodel (= 3.0.3)
|
10
|
+
activesupport (= 3.0.3)
|
11
|
+
builder (~> 2.1.2)
|
12
|
+
erubis (~> 2.6.6)
|
13
|
+
i18n (~> 0.4)
|
14
|
+
rack (~> 1.2.1)
|
15
|
+
rack-mount (~> 0.6.13)
|
16
|
+
rack-test (~> 0.5.6)
|
17
|
+
tzinfo (~> 0.3.23)
|
18
|
+
activemodel (3.0.3)
|
19
|
+
activesupport (= 3.0.3)
|
20
|
+
builder (~> 2.1.2)
|
21
|
+
i18n (~> 0.4)
|
22
|
+
activerecord (3.0.3)
|
23
|
+
activemodel (= 3.0.3)
|
24
|
+
activesupport (= 3.0.3)
|
25
|
+
arel (~> 2.0.2)
|
26
|
+
tzinfo (~> 0.3.23)
|
27
|
+
activeresource (3.0.3)
|
28
|
+
activemodel (= 3.0.3)
|
29
|
+
activesupport (= 3.0.3)
|
30
|
+
activesupport (3.0.3)
|
31
|
+
arel (2.0.7)
|
32
|
+
builder (2.1.2)
|
33
|
+
erubis (2.6.6)
|
34
|
+
abstract (>= 1.0.0)
|
35
|
+
faker (0.9.4)
|
36
|
+
i18n (~> 0.4)
|
37
|
+
git (1.2.5)
|
38
|
+
haml (3.0.25)
|
39
|
+
i18n (0.5.0)
|
40
|
+
jeweler (1.5.2)
|
41
|
+
bundler (~> 1.0.0)
|
42
|
+
git (>= 1.2.5)
|
43
|
+
rake
|
44
|
+
mail (2.2.14)
|
45
|
+
activesupport (>= 2.3.6)
|
46
|
+
i18n (>= 0.4.0)
|
47
|
+
mime-types (~> 1.16)
|
48
|
+
treetop (~> 1.4.8)
|
49
|
+
mime-types (1.16)
|
50
|
+
polyglot (0.3.1)
|
51
|
+
rack (1.2.1)
|
52
|
+
rack-mount (0.6.13)
|
53
|
+
rack (>= 1.0.0)
|
54
|
+
rack-test (0.5.7)
|
55
|
+
rack (>= 1.0)
|
56
|
+
rails (3.0.3)
|
57
|
+
actionmailer (= 3.0.3)
|
58
|
+
actionpack (= 3.0.3)
|
59
|
+
activerecord (= 3.0.3)
|
60
|
+
activeresource (= 3.0.3)
|
61
|
+
activesupport (= 3.0.3)
|
62
|
+
bundler (~> 1.0)
|
63
|
+
railties (= 3.0.3)
|
64
|
+
railties (3.0.3)
|
65
|
+
actionpack (= 3.0.3)
|
66
|
+
activesupport (= 3.0.3)
|
67
|
+
rake (>= 0.8.7)
|
68
|
+
thor (~> 0.14.4)
|
69
|
+
rake (0.8.7)
|
70
|
+
sqlite3 (1.3.3)
|
71
|
+
sqlite3-ruby (1.3.3)
|
72
|
+
sqlite3 (>= 1.3.3)
|
73
|
+
test_dummy (0.2.6)
|
74
|
+
thor (0.14.6)
|
75
|
+
treetop (1.4.9)
|
76
|
+
polyglot (>= 0.3.1)
|
77
|
+
tzinfo (0.3.24)
|
78
|
+
|
79
|
+
PLATFORMS
|
80
|
+
ruby
|
81
|
+
|
82
|
+
DEPENDENCIES
|
83
|
+
faker
|
84
|
+
haml (= 3.0.25)
|
85
|
+
jeweler
|
86
|
+
rails (= 3.0.3)
|
87
|
+
sqlite3-ruby
|
88
|
+
test_dummy
|
data/README.md
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
# Wristband
|
2
|
+
Author: [The Working Group](http://www.theworkinggroup.ca)
|
3
|
+
|
4
|
+
---
|
5
|
+
|
6
|
+
## What is it?
|
7
|
+
|
8
|
+
Wristband provides a starting point for user authentication.
|
9
|
+
|
10
|
+
It handles:
|
11
|
+
|
12
|
+
* Login and logout
|
13
|
+
* Password storage with encryption
|
14
|
+
* Remember me functionality
|
15
|
+
* Authority definitions
|
16
|
+
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
### 1. Add gem definition to your Gemfile:
|
21
|
+
|
22
|
+
config.gem 'wristband'
|
23
|
+
|
24
|
+
### 2. From withing your Rails project run:
|
25
|
+
|
26
|
+
bundle install
|
27
|
+
|
28
|
+
### 3. (optional) Run the wristband generator:
|
29
|
+
|
30
|
+
rails g wristband
|
31
|
+
|
32
|
+
This will output something like:
|
33
|
+
|
34
|
+
create app/models/user.rb
|
35
|
+
create app/models/session_user.rb
|
36
|
+
create app/controllers/users_controller.rb
|
37
|
+
create app/controllers/sessions_controller.rb
|
38
|
+
create app/views/users/show.html.haml
|
39
|
+
create app/views/sessions/new.html.haml
|
40
|
+
create app/mailers/user_mailer.rb
|
41
|
+
create app/views/user_mailer/forgot_password.text.html.rhtml
|
42
|
+
create app/views/user_mailer/forgot_password.text.plain.rhtml
|
43
|
+
create app/views/user_mailer/email_verification.text.html.rhtml
|
44
|
+
create app/views/user_mailer/email_verification.text.plain.rhtml
|
45
|
+
create db/migrate/20110123214541_create_users_table.rb
|
46
|
+
|
47
|
+
### 4. (optional) Run migrations:
|
48
|
+
|
49
|
+
rake db:migrate
|
50
|
+
|
51
|
+
|
52
|
+
## Configuration
|
53
|
+
|
54
|
+
|
55
|
+
### In your User model
|
56
|
+
|
57
|
+
class User < ActiveRecord::Base
|
58
|
+
wristband [options]
|
59
|
+
end
|
60
|
+
|
61
|
+
### Options:
|
62
|
+
|
63
|
+
**:login_with** - Array of fields you want to authenticate the user with. Default: email
|
64
|
+
|
65
|
+
wristband :login_with => [:username, :email]
|
66
|
+
|
67
|
+
|
68
|
+
**:before_authentication** - Array of functions run after the user authentication takes place. Default: []
|
69
|
+
|
70
|
+
wristband :before_authentication => :do_something
|
71
|
+
|
72
|
+
|
73
|
+
**:after_authentication** - Array of functions run before the user authentication takes place. Default: []
|
74
|
+
|
75
|
+
wristband :after_authentication => :do_something
|
76
|
+
|
77
|
+
|
78
|
+
**:has_authorities** - The different user authorities are defined in a separate class so as to reduce clutter in the User model itself. Default: false
|
79
|
+
|
80
|
+
wristband :has_authorities => true
|
81
|
+
|
82
|
+
**:roles** - Use this to define the different roles the user can assume. Make sure you have a role column on your users table. It will generate functions like `is_<role>?` for each one of the roles youdefine.
|
83
|
+
|
84
|
+
wristband :roles => [:regular_user, :admin]
|
85
|
+
|
86
|
+
will generate `user.is_regular_user?` and `user.is_admin?`
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
## Notes
|
91
|
+
|
92
|
+
1. **Remember me** - If you want to automatically login a user when he comes back to your site, add `before_filter :login_from_cookie` to your AplicationController.
|
93
|
+
2. **Authority Definitions** - Checkout the documentation on wristband/authority_check_rb
|
94
|
+
|
95
|
+
|
96
|
+
## Database configuration
|
97
|
+
|
98
|
+
The generator gives you a head start.
|
99
|
+
The basic columns are defined as such:
|
100
|
+
|
101
|
+
create_table :users do |t|
|
102
|
+
t.string :email
|
103
|
+
t.string :email_validation_key
|
104
|
+
t.datetime :validated_at
|
105
|
+
t.string :password_crypt, :limit => 40
|
106
|
+
t.string :password_salt, :limit => 40
|
107
|
+
t.string :remember_token
|
108
|
+
t.string :role
|
109
|
+
t.timestamps
|
110
|
+
end
|
111
|
+
|
112
|
+
|
113
|
+
Have fun!!
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.expand_path('../config/application', __FILE__)
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
Wristband::Application.load_tasks
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'jeweler'
|
8
|
+
Jeweler::Tasks.new do |gem|
|
9
|
+
gem.name = 'wristband'
|
10
|
+
gem.summary = 'An authentication engine'
|
11
|
+
gem.description = 'Provides a starting point for user authentication'
|
12
|
+
gem.email = 'jack@theworkinggroup.ca'
|
13
|
+
gem.homepage = 'http://github.com/twg/wristband'
|
14
|
+
gem.authors = ['Jack Neto', 'The Working Group Inc']
|
15
|
+
gem.add_dependency('rails', '>=3.0.3')
|
16
|
+
gem.add_dependency('haml', '>=3.0.25')
|
17
|
+
end
|
18
|
+
Jeweler::GemcutterTasks.new
|
19
|
+
rescue LoadError
|
20
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
21
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.0
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class SessionsController < ApplicationController
|
2
|
+
before_filter :login_required, :only => :destroy
|
3
|
+
before_filter :redirect_if_logged_in, :only => [ :new, :create, :forgot_password ]
|
4
|
+
before_filter :build_user_session, :only => [ :new, :create ]
|
5
|
+
|
6
|
+
def create
|
7
|
+
if @session_user.save
|
8
|
+
login(@session_user)
|
9
|
+
flash[:notice] = "Welcome, you are now logged in."
|
10
|
+
redirect_to user_path(current_user)
|
11
|
+
else
|
12
|
+
flash[:error] = 'Login failed. Did you mistype?'
|
13
|
+
render :action => :new
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def destroy
|
18
|
+
logout
|
19
|
+
redirect_to root_path
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
def build_user_session
|
24
|
+
@session_user = SessionUser.new(params[:session_user])
|
25
|
+
end
|
26
|
+
|
27
|
+
def redirect_if_logged_in
|
28
|
+
redirect_to root_path if logged_in?
|
29
|
+
end
|
30
|
+
|
31
|
+
def login_required
|
32
|
+
redirect_to login_path unless logged_in?
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class UsersController < ApplicationController
|
2
|
+
before_filter :login_required
|
3
|
+
|
4
|
+
def verify_email
|
5
|
+
@user = User.verify_email!(params[:email_validation_key])
|
6
|
+
flash[:notice] = 'Your email address has been verified. You may now login to your account.'
|
7
|
+
redirect_to login_path
|
8
|
+
rescue UserVerificationError => error
|
9
|
+
flash[:error] = error.message
|
10
|
+
redirect_to login_path
|
11
|
+
end
|
12
|
+
|
13
|
+
def forgot_password
|
14
|
+
if request.post?
|
15
|
+
if @user = User.find_by_email(params[:user][:email])
|
16
|
+
@user.password = Wristband::Support.random_string(6)
|
17
|
+
@user.save!
|
18
|
+
UserNotifier::deliver_forgot_password(@user)
|
19
|
+
flash[:notice] = 'A new password has been generated and emailed to the address you entered.'
|
20
|
+
redirect_to login_path and return
|
21
|
+
else
|
22
|
+
@user = User.new
|
23
|
+
@user.errors.add("email", "Cannot find that email address, did you mistype?")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
private
|
30
|
+
def login_required
|
31
|
+
redirect_to login_path unless logged_in?
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
class UserMailer < ActionMailer::Base
|
2
|
+
default :from => "from@example.com"
|
3
|
+
|
4
|
+
default_url_options[:host] = HOST_NAME
|
5
|
+
|
6
|
+
def email_verification(user)
|
7
|
+
setup_email(user)
|
8
|
+
@subject += "Your account has been created. Please verify your email address"
|
9
|
+
end
|
10
|
+
|
11
|
+
def forgot_password(user)
|
12
|
+
setup_email(user)
|
13
|
+
@subject += "You have requested a new password"
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
protected
|
18
|
+
# Change YourApp to whatever you application is called
|
19
|
+
def setup_email(user)
|
20
|
+
@recipients = user.email
|
21
|
+
@body[:user] = user
|
22
|
+
@from = FROM_EMAIL
|
23
|
+
@subject = case ENV['RAILS_ENV']
|
24
|
+
when 'development'
|
25
|
+
"[YourApp Development] "
|
26
|
+
when 'staging'
|
27
|
+
"[YourApp Staging] "
|
28
|
+
else "[YourApp] "
|
29
|
+
end
|
30
|
+
@sent_on = Time.now
|
31
|
+
headers "Reply-to" => FROM_EMAIL
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
class SessionUser
|
2
|
+
include ActiveModel::Validations
|
3
|
+
|
4
|
+
# == Attribute ==========================================================
|
5
|
+
|
6
|
+
attr_accessor :email
|
7
|
+
attr_accessor :password
|
8
|
+
attr_accessor :remember_me
|
9
|
+
attr_accessor :user
|
10
|
+
|
11
|
+
# == Validations ==========================================================
|
12
|
+
|
13
|
+
validates :email,
|
14
|
+
:presence => {:message => 'Please enter your email address'},
|
15
|
+
:length => {
|
16
|
+
:within => 6..100,
|
17
|
+
:too_short => "The email address you entered is to short"
|
18
|
+
},
|
19
|
+
:format => {
|
20
|
+
:with => /^([\w.%-+]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i,
|
21
|
+
:message => 'The email address you entered is not valid'
|
22
|
+
}
|
23
|
+
|
24
|
+
validates :password,
|
25
|
+
:length => {
|
26
|
+
:within => 4..40,
|
27
|
+
:too_short => "The password you entered is too short (minimum is 4 characters)"
|
28
|
+
},
|
29
|
+
:presence => {
|
30
|
+
:message => 'Please choose a password'
|
31
|
+
},
|
32
|
+
:confirmation => {:message => "The password you entered does not match with the confirmation"}
|
33
|
+
|
34
|
+
# == Class Methods ========================================================
|
35
|
+
|
36
|
+
def self.create(params={})
|
37
|
+
session_user = self.new(params)
|
38
|
+
session_user.save
|
39
|
+
session_user
|
40
|
+
end
|
41
|
+
|
42
|
+
# == Instance Methods =====================================================
|
43
|
+
|
44
|
+
def initialize(params = {})
|
45
|
+
if params
|
46
|
+
@email = params[:email]
|
47
|
+
@password = params[:password]
|
48
|
+
@remember_me = params[:remember_me]
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def save
|
53
|
+
@user = User.authenticate(self.email, self.password) if self.valid?
|
54
|
+
end
|
55
|
+
|
56
|
+
def to_key
|
57
|
+
nil
|
58
|
+
end
|
59
|
+
end
|
data/app/models/user.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
class User < ActiveRecord::Base
|
2
|
+
|
3
|
+
# == Constants ============================================================
|
4
|
+
|
5
|
+
ROLES = [:admin, :regular_user]
|
6
|
+
|
7
|
+
# == Extensions ===========================================================
|
8
|
+
|
9
|
+
wristband :roles => ROLES
|
10
|
+
|
11
|
+
# == Validations ==========================================================
|
12
|
+
|
13
|
+
validates :email,
|
14
|
+
:presence => {:message => 'Please enter your email address'},
|
15
|
+
:length => {
|
16
|
+
:within => 6..100,
|
17
|
+
:too_short => "The email address you entered is to short"
|
18
|
+
},
|
19
|
+
:format => {
|
20
|
+
:with => /^([\w.%-+]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i,
|
21
|
+
:message => 'The email address you entered is not valid'
|
22
|
+
},
|
23
|
+
:uniqueness => true
|
24
|
+
|
25
|
+
validates :password,
|
26
|
+
:length => {
|
27
|
+
:within => 4..40,
|
28
|
+
:too_short => "The password you entered is too short (minimum is 4 characters)"
|
29
|
+
},
|
30
|
+
:presence => {
|
31
|
+
:message => 'Please choose a password',
|
32
|
+
:if => :password_required?
|
33
|
+
},
|
34
|
+
:confirmation => {:message => "The password you entered does not match with the confirmation"}
|
35
|
+
|
36
|
+
validates :role,
|
37
|
+
:inclusion => { :in => ROLES },
|
38
|
+
:presence => true
|
39
|
+
|
40
|
+
# == Scopes ===============================================================
|
41
|
+
|
42
|
+
# == Callbacks ============================================================
|
43
|
+
|
44
|
+
# == Class Methods ========================================================
|
45
|
+
|
46
|
+
# == Instance Methods =====================================================
|
47
|
+
|
48
|
+
def password_required?
|
49
|
+
self.new_record?
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
%h1 Login
|
2
|
+
|
3
|
+
= formatted_form_for @session_user, :url => login_path do |f|
|
4
|
+
= f.text_field :email, :label => 'Email address'
|
5
|
+
= f.password_field :password
|
6
|
+
= f.check_box :remember_me, :label => 'Remember me when I come back'
|
7
|
+
= f.submit 'Log In'
|
8
|
+
|
9
|
+
%p
|
10
|
+
Did you forget your password?
|
11
|
+
= link_to 'Recover it here.', forgot_password_path
|
12
|
+
%p
|
13
|
+
If you don't have a login yet, click
|
14
|
+
= link_to 'here', register_path
|
15
|
+
to register.
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<p>Hi,</p>
|
2
|
+
|
3
|
+
<p>A new password was requested for this email address.</p>
|
4
|
+
|
5
|
+
<p>Your new password is: <b><%= @user.password %></b> </p>
|
6
|
+
|
7
|
+
<p><%= link_to 'Click here to login', login_url %>.</p>
|
8
|
+
<p>Once you have logged in, you can edit your profile and change your password to something you can easily remember.</p>
|
9
|
+
|
10
|
+
<p>Thanks</p>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Hi,
|
2
|
+
|
3
|
+
A new password was requested for this email address.
|
4
|
+
|
5
|
+
Your new password is: <b><%= @user.password %></b>
|
6
|
+
|
7
|
+
To login go to: <%= login_url %>.
|
8
|
+
Once you have logged in, you can edit your profile and change your password to something you can easily remember.
|
9
|
+
|
10
|
+
Thanks
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require 'rails/all'
|
4
|
+
|
5
|
+
# If you have a Gemfile, require the gems listed there, including any gems
|
6
|
+
# you've limited to :test, :development, or :production.
|
7
|
+
Bundler.require(:default, Rails.env) if defined?(Bundler)
|
8
|
+
|
9
|
+
module Wristband
|
10
|
+
class Application < Rails::Application
|
11
|
+
config.encoding = "utf-8"
|
12
|
+
|
13
|
+
config.filter_parameters += [:password]
|
14
|
+
end
|
15
|
+
end
|
data/config/boot.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
# Set up gems listed in the Gemfile.
|
4
|
+
gemfile = File.expand_path('../../Gemfile', __FILE__)
|
5
|
+
begin
|
6
|
+
ENV['BUNDLE_GEMFILE'] = gemfile
|
7
|
+
require 'bundler'
|
8
|
+
Bundler.setup
|
9
|
+
rescue Bundler::GemNotFound => e
|
10
|
+
STDERR.puts e.message
|
11
|
+
STDERR.puts "Try running `bundle install`."
|
12
|
+
exit!
|
13
|
+
end if File.exist?(gemfile)
|
data/config/database.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# SQLite version 3.x
|
2
|
+
# gem install sqlite3-ruby (not necessary on OS X Leopard)
|
3
|
+
development:
|
4
|
+
adapter: sqlite3
|
5
|
+
database: db/development.sqlite3
|
6
|
+
pool: 5
|
7
|
+
timeout: 5000
|
8
|
+
|
9
|
+
# Warning: The database defined as "test" will be erased and
|
10
|
+
# re-generated from your development database when you run "rake".
|
11
|
+
# Do not set this db to the same as development or production.
|
12
|
+
test:
|
13
|
+
adapter: sqlite3
|
14
|
+
database: db/test.sqlite3
|
15
|
+
pool: 5
|
16
|
+
timeout: 5000
|
@@ -0,0 +1,26 @@
|
|
1
|
+
Wristband::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# In the development environment your application's code is reloaded on
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the webserver when you make code changes.
|
7
|
+
config.cache_classes = false
|
8
|
+
|
9
|
+
# Log error messages when you accidentally call methods on nil.
|
10
|
+
config.whiny_nils = true
|
11
|
+
|
12
|
+
# Show full error reports and disable caching
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
config.action_view.debug_rjs = true
|
15
|
+
config.action_controller.perform_caching = false
|
16
|
+
|
17
|
+
# Don't care if the mailer can't send
|
18
|
+
config.action_mailer.raise_delivery_errors = false
|
19
|
+
|
20
|
+
# Print deprecation notices to the Rails logger
|
21
|
+
config.active_support.deprecation = :log
|
22
|
+
|
23
|
+
# Only use best-standards-support built into browsers
|
24
|
+
config.action_dispatch.best_standards_support = :builtin
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,49 @@
|
|
1
|
+
Wristband::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# The production environment is meant for finished, "live" apps.
|
5
|
+
# Code is not reloaded between requests
|
6
|
+
config.cache_classes = true
|
7
|
+
|
8
|
+
# Full error reports are disabled and caching is turned on
|
9
|
+
config.consider_all_requests_local = false
|
10
|
+
config.action_controller.perform_caching = true
|
11
|
+
|
12
|
+
# Specifies the header that your server uses for sending files
|
13
|
+
config.action_dispatch.x_sendfile_header = "X-Sendfile"
|
14
|
+
|
15
|
+
# For nginx:
|
16
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
|
17
|
+
|
18
|
+
# If you have no front-end server that supports something like X-Sendfile,
|
19
|
+
# just comment this out and Rails will serve the files
|
20
|
+
|
21
|
+
# See everything in the log (default is :info)
|
22
|
+
# config.log_level = :debug
|
23
|
+
|
24
|
+
# Use a different logger for distributed setups
|
25
|
+
# config.logger = SyslogLogger.new
|
26
|
+
|
27
|
+
# Use a different cache store in production
|
28
|
+
# config.cache_store = :mem_cache_store
|
29
|
+
|
30
|
+
# Disable Rails's static asset server
|
31
|
+
# In production, Apache or nginx will already do this
|
32
|
+
config.serve_static_assets = false
|
33
|
+
|
34
|
+
# Enable serving of images, stylesheets, and javascripts from an asset server
|
35
|
+
# config.action_controller.asset_host = "http://assets.example.com"
|
36
|
+
|
37
|
+
# Disable delivery errors, bad email addresses will be ignored
|
38
|
+
# config.action_mailer.raise_delivery_errors = false
|
39
|
+
|
40
|
+
# Enable threaded mode
|
41
|
+
# config.threadsafe!
|
42
|
+
|
43
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
44
|
+
# the I18n.default_locale when a translation can not be found)
|
45
|
+
config.i18n.fallbacks = true
|
46
|
+
|
47
|
+
# Send deprecation notices to registered listeners
|
48
|
+
config.active_support.deprecation = :notify
|
49
|
+
end
|