Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

build using rails_apps_composer 2.2.29

  • Loading branch information...
commit 887553337e215b002b9edba1a8ee83e0ca725c70 1 parent 16a925c
@DanielKehoe DanielKehoe authored
View
2  .gitignore
@@ -6,7 +6,7 @@
# The original version of this file is found here:
# https://github.com/RailsApps/rails-composer/blob/master/files/gitignore.txt
#
-# Corrections? Improvements? Create a GitHub issue:
+# Corrections? Improvements? Create a GitHub issue:
# http://github.com/RailsApps/rails-composer/issues
#----------------------------------------------------------------------------
View
9 Gemfile
@@ -7,12 +7,15 @@ group :assets do
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
-gem "rspec-rails", ">= 2.12.1", :group => [:development, :test]
+gem "rspec-rails", ">= 2.12.2", :group => [:development, :test]
gem "database_cleaner", ">= 0.9.1", :group => :test
gem "email_spec", ">= 1.4.0", :group => :test
gem "cucumber-rails", ">= 1.3.0", :group => :test, :require => false
gem "launchy", ">= 2.1.2", :group => :test
-gem "capybara", ">= 2.0.2", :group => :test
+gem "capybara", ">= 2.0.1", :group => :test
gem "factory_girl_rails", ">= 4.1.0", :group => [:development, :test]
-gem "devise", ">= 2.2.0"
+gem "devise", ">= 2.2.2"
gem "quiet_assets", ">= 1.0.1", :group => :development
+gem "figaro", ">= 0.5.3"
+gem "better_errors", ">= 0.3.2", :group => :development
+gem "binding_of_caller", ">= 0.6.8", :group => :development
View
30 Gemfile.lock
@@ -31,6 +31,10 @@ GEM
addressable (2.3.2)
arel (3.0.2)
bcrypt-ruby (3.0.1)
+ better_errors (0.3.2)
+ coderay (>= 1.0.0)
+ erubis (>= 2.7.0)
+ binding_of_caller (0.6.8)
builder (3.0.4)
capybara (2.0.2)
mime-types (>= 1.16)
@@ -41,6 +45,7 @@ GEM
xpath (~> 1.0.0)
childprocess (0.3.6)
ffi (~> 1.0, >= 1.0.6)
+ coderay (1.0.8)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
railties (~> 3.2.0)
@@ -58,7 +63,7 @@ GEM
cucumber (>= 1.1.8)
nokogiri (>= 1.5.0)
database_cleaner (0.9.1)
- devise (2.2.0)
+ devise (2.2.2)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.1)
railties (~> 3.1)
@@ -75,13 +80,15 @@ GEM
factory_girl_rails (4.1.0)
factory_girl (~> 4.1.0)
railties (>= 3.0.0)
- ffi (1.3.0)
+ ffi (1.3.1)
+ figaro (0.5.3)
+ rails (~> 3.0)
gherkin (2.11.5)
json (>= 1.4.6)
hike (1.2.1)
i18n (0.6.1)
journey (1.0.4)
- jquery-rails (2.1.4)
+ jquery-rails (2.2.0)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
json (1.7.6)
@@ -101,7 +108,7 @@ GEM
polyglot (0.3.3)
quiet_assets (1.0.1)
railties (~> 3.1)
- rack (1.4.3)
+ rack (1.4.4)
rack-cache (1.2)
rack (>= 0.4)
rack-ssl (1.3.2)
@@ -130,7 +137,7 @@ GEM
rspec-expectations (2.12.1)
diff-lcs (~> 1.1.3)
rspec-mocks (2.12.1)
- rspec-rails (2.12.1)
+ rspec-rails (2.12.2)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
@@ -139,7 +146,7 @@ GEM
rspec-mocks (~> 2.12.0)
rubyzip (0.9.9)
sass (3.2.5)
- sass-rails (3.2.5)
+ sass-rails (3.2.6)
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
@@ -153,7 +160,7 @@ GEM
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
- sqlite3 (1.3.6)
+ sqlite3 (1.3.7)
thor (0.16.0)
tilt (1.3.3)
treetop (1.4.12)
@@ -173,18 +180,21 @@ PLATFORMS
ruby
DEPENDENCIES
- capybara (>= 2.0.2)
+ better_errors (>= 0.3.2)
+ binding_of_caller (>= 0.6.8)
+ capybara (>= 2.0.1)
coffee-rails (~> 3.2.1)
cucumber-rails (>= 1.3.0)
database_cleaner (>= 0.9.1)
- devise (>= 2.2.0)
+ devise (>= 2.2.2)
email_spec (>= 1.4.0)
factory_girl_rails (>= 4.1.0)
+ figaro (>= 0.5.3)
jquery-rails
launchy (>= 2.1.2)
quiet_assets (>= 1.0.1)
rails (= 3.2.11)
- rspec-rails (>= 2.12.1)
+ rspec-rails (>= 2.12.2)
sass-rails (~> 3.2.3)
sqlite3
uglifier (>= 1.0.3)
96 README.textile
@@ -26,8 +26,6 @@ h2. What Is Implemented -- and What Is Not
This is a demonstration application that allows you to visit a home page and see a list of users. With the default user's email and password (supplied below), you can log in and view details for each user. Devise provides user management so a visitor can register with an email address and password and create an account. Devise provides authentication so access to the site can be limited to users who are registered and logged in.
-The @rake db:seed@ command sets up a database with two example users. The first user is designated as an administrator and can view a administrative page when logged in. The second user is restricted from accessing the administrative page.
-
h4. Similar Examples and Tutorials
This is one in a series of Rails example apps and tutorials from the "RailsApps Project":http://railsapps.github.com/. See a list of additional "Rails examples, tutorials, and starter apps":http://railsapps.github.com/rails-examples-tutorials.html.
@@ -72,27 +70,28 @@ If you want to use the project as a starter app, use the "Rails Composer":http:/
To build the example application, run the command:
<pre>
-$ rails new myapp -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb -T
+$ rails new rails3-devise-rspec-cucumber -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb -T
</pre>
Use the @-T@ flag to skip Test::Unit files.
The @$@ character indicates a shell prompt; don't include it when you run the command.
-This creates a new Rails app (with the name "myapp") on your computer. You can use a different name if you wish.
+This creates a new Rails app named @rails3-devise-rspec-cucumber@ on your computer. You can use a different name if you wish.
You'll see a prompt:
<pre>
question Install an example application?
- 1) I want to build my own application
- 2) rails3-bootstrap-devise-cancan
- 3) rails3-devise-rspec-cucumber
- 4) rails3-mongoid-devise
- 5) rails3-mongoid-omniauth
- 6) rails3-subdomains
+ 1) I want to build my own application
+ 2) membership/subscription/saas
+ 3) rails-prelaunch-signup
+ 4) rails3-bootstrap-devise-cancan
+ 5) rails3-devise-rspec-cucumber
+ 6) rails3-mongoid-devise
+ 7) rails3-mongoid-omniauth
+ 8) rails3-subdomains
</pre>
-
Choose *rails3-devise-rspec-cucumber*. The Rails Composer tool may give you other options (other choices may have been added since these notes were written).
The application generator template will ask you for additional preferences:
@@ -189,22 +188,59 @@ You can modify the configuration file for Devise if you want to use something ot
* *config/initializers/devise.rb*
-h2. Create a Default User
+h3. Configuration File
+
+The application uses the "figaro gem":https://github.com/laserlemon/figaro to set environment variables. Credentials for your administrator account and email account are set in the *config/application.yml* file. The *.gitignore* file prevents the *config/application.yml* file from being saved in the git repository so your credentials are kept private. See the article "Rails Environment Variables":http://railsapps.github.com/rails-environment-variables.html for more information.
+
+Modify the file *config/application.yml*:
+
+<pre>
+# Add account credentials and API keys here.
+# See http://railsapps.github.com/rails-environment-variables.html
+# This file should be listed in .gitignore to keep your settings secret!
+# Each entry sets a local environment variable and overrides ENV variables in the Unix shell.
+# For example, setting:
+# GMAIL_USERNAME: Your_Gmail_Username
+# makes 'Your_Gmail_Username' available as ENV["GMAIL_USERNAME"]
+# Add application configuration variables here, as shown below.
+#
+GMAIL_USERNAME: Your_Username
+GMAIL_PASSWORD: Your_Password
+ADMIN_NAME: First User
+ADMIN_EMAIL: user@example.com
+ADMIN_PASSWORD: changeme
+</pre>
+
+If you are planning to customize the application to send email using a Gmail acocunt, you can add the user name and password needed for the application to send email. See the article "Send Email with Rails":http://railsapps.github.com/rails-send-email.html.
+
+If you wish, set your name, email address, and password for the first user's account. If you prefer, you can use the default to sign in to the application and edit the account after deployment. It is always a good idea to change the password after the application is deployed.
+
+All configuration values in the *config/application.yml* file are available anywhere in the application as environment variables. For example, @ENV["GMAIL_USERNAME"]@ will return the string "Your_Username".
+
+If you prefer, you can delete the *config/application.yml* file and set each value as an environment variable in the Unix shell.
h3. Set Up a Database Seed File
-You'll want to set up a default user so you can easily log in to test the app. You can modify the file *db/seeds.rb* for your own name, email and password:
+The *db/seeds.rb* file initializes the database with default values. To keep some data private, and consolidate configuration settings in a single location, we use the *config/application.yml* file to set environment variables and then use the environment variables in the *db/seeds.rb* file.
<pre>
-puts 'SETTING UP DEFAULT USER LOGIN'
-user = User.create! :name => 'First User', :email => 'user@example.com', :password => 'please', :password_confirmation => 'please'
-puts 'New user created: ' << user.name
-user2 = User.create! :name => 'Second User', :email => 'user2@example.com', :password => 'please', :password_confirmation => 'please'
-puts 'New user created: ' << user2.name
-user.add_role :admin
+puts 'DEFAULT USERS'
+user = User.find_or_create_by_email :name => ENV['ADMIN_NAME'].dup, :email => ENV['ADMIN_EMAIL'].dup, :password => ENV['ADMIN_PASSWORD'].dup, :password_confirmation => ENV['ADMIN_PASSWORD'].dup
+puts 'user: ' << user.name
</pre>
-Use the defaults or change the values for name, email, and password as you wish.
+You can change the first user's name, email, and password in this file but it is better to make the changes in the *config/application.yml* file to keep the credentials private. If you decide to include your private password in the *db/seeds.rb* file, be sure to add the filename to your *.gitignore* file so that your password doesn't become available in your public GitHub repository.
+
+Note that it's not necessary to personalize the *db/seeds.rb* file before you deploy your app. You can deploy the app with an example user and then use the application's "Edit Account" feature to change name, email address, and password after you log in. Use this feature to log in as the first user and change the user name and password to your own.
+
+You may wish to include additional sample users:
+
+<pre>
+user2 = User.find_or_create_by_email :name => 'Second User', :email => 'user2@example.com', :password => 'changeme', :password_confirmation => 'changeme'
+puts 'user: ' << user2.name
+</pre>
+
+This will add a second user to the database.
h3. Set the Database
@@ -215,6 +251,8 @@ $ rake db:migrate
$ rake db:seed
</pre>
+Use @rake db:reset@ if you want to empty and reseed the database.
+
Set the database for running tests:
<pre>
@@ -223,6 +261,24 @@ $ rake db:test:prepare
If you’re not using "rvm":https://rvm.io/, the Ruby Version Manager, you should preface each rake command with @bundle exec@. You don’t need to use @bundle exec@ if you are using rvm version 1.11.0 or newer.
+h3. Change your Application's Secret Token
+
+If you've used the Rails Composer tool to generate the application, the application's secret token will be unique, just as with any Rails application generated with the @rails new@ command.
+
+However, if you've cloned the application directly from GitHub, it is crucial that you change the application's secret token before deploying your application in production mode. Otherwise, people could change their session information, and potentially access your SaaS or membership site as a premium user or administrator. Your secret token should be at least 30 characters long and completely random.
+
+Get a unique secret token:
+
+<pre>
+rake secret
+</pre>
+
+Edit your *config/initializers/secret_token.rb* file to add the secret token:
+
+<pre>
+Rails3BootstrapDeviseCancan::Application.config.secret_token = '...some really long, random string...'
+</pre>
+
h2. Test the App
You can check that your app runs properly by entering the command
View
2  app/views/devise/shared/_links.html.erb
@@ -22,4 +22,4 @@
<%- resource_class.omniauth_providers.each do |provider| %>
<%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %><br />
<% end -%>
-<% end -%>
+<% end -%>
View
2  app/views/home/index.html.erb
@@ -1,4 +1,4 @@
<h3>Home</h3>
<% @users.each do |user| %>
<p>User: <%=link_to user.name, user %></p>
-<% end %>
+<% end %>
View
2  app/views/layouts/_messages.html.erb
@@ -2,4 +2,4 @@
<% if msg.is_a?(String) %>
<%= content_tag :div, msg, :id => "flash_#{name}" %>
<% end %>
-<% end %>
+<% end %>
View
6 app/views/layouts/_navigation.html.erb
@@ -2,11 +2,11 @@
<ul class="nav">
<% if user_signed_in? %>
<li>
- <%= link_to 'Logout', destroy_user_session_path, :method=>'delete' %>
+ <%= link_to 'Logout', destroy_user_session_path, :method=>'delete' %>
</li>
<% else %>
<li>
- <%= link_to 'Login', new_user_session_path %>
+ <%= link_to 'Login', new_user_session_path %>
</li>
<% end %>
<% if user_signed_in? %>
@@ -18,4 +18,4 @@
<%= link_to 'Sign up', new_user_registration_path %>
</li>
<% end %>
-</ul>
+</ul>
View
2  app/views/users/index.html.erb
@@ -5,4 +5,4 @@
<%= link_to user.name, user %> signed up <%= user.created_at.to_date %>
</li>
<% end %>
-</ul>
+</ul>
View
2  app/views/users/show.html.erb
@@ -1,3 +1,3 @@
<h3>User</h3>
<p>User: <%= @user.name %></p>
-<p>Email: <%= @user.email if @user.email %></p>
+<p>Email: <%= @user.email if @user.email %></p>
View
14 config/application.example.yml
@@ -0,0 +1,14 @@
+# Add account credentials and API keys here.
+# See http://railsapps.github.com/rails-environment-variables.html
+# This file should be listed in .gitignore to keep your settings secret!
+# Each entry sets a local environment variable and overrides ENV variables in the Unix shell.
+# For example, setting:
+# GMAIL_USERNAME: Your_Gmail_Username
+# makes 'Your_Gmail_Username' available as ENV["GMAIL_USERNAME"]
+# Add application configuration variables here, as shown below.
+#
+GMAIL_USERNAME: Your_Username
+GMAIL_PASSWORD: Your_Password
+ADMIN_NAME: First User
+ADMIN_EMAIL: user@example.com
+ADMIN_PASSWORD: changeme
View
14 config/application.yml
@@ -0,0 +1,14 @@
+# Add account credentials and API keys here.
+# See http://railsapps.github.com/rails-environment-variables.html
+# This file should be listed in .gitignore to keep your settings secret!
+# Each entry sets a local environment variable and overrides ENV variables in the Unix shell.
+# For example, setting:
+# GMAIL_USERNAME: Your_Gmail_Username
+# makes 'Your_Gmail_Username' available as ENV["GMAIL_USERNAME"]
+# Add application configuration variables here, as shown below.
+#
+GMAIL_USERNAME: Your_Username
+GMAIL_PASSWORD: Your_Password
+ADMIN_NAME: First User
+ADMIN_EMAIL: user@example.com
+ADMIN_PASSWORD: changeme
View
12 config/initializers/devise.rb
@@ -92,6 +92,14 @@
# the user cannot access the website without confirming his account.
# config.allow_unconfirmed_access_for = 2.days
+ # A period that the user is allowed to confirm their account before their
+ # token becomes invalid. For example, if set to 3.days, the user can confirm
+ # their account within 3 days after the mail was sent, but on the fourth day
+ # their account can't be confirmed with the token any more.
+ # Default is nil, meaning there is no restriction on how long a user can take
+ # before confirming their account.
+ # config.confirm_within = 3.days
+
# If true, requires any email changes to be confirmed (exactly the same way as
# initial account confirmation) to be applied. Requires additional unconfirmed_email
# db field (see migrations). Until confirmed new email is stored in
@@ -113,8 +121,8 @@
# config.rememberable_options = {}
# ==> Configuration for :validatable
- # Range for password length. Default is 6..128.
- # config.password_length = 6..128
+ # Range for password length. Default is 8..128.
+ config.password_length = 8..128
# Email regex used to validate email formats. It simply asserts that
# an one (and only one) @ exists in the given string. This is mainly
View
2  config/locales/devise.en.yml
@@ -10,6 +10,7 @@ en:
not_saved:
one: "1 error prohibited this %{resource} from being saved:"
other: "%{count} errors prohibited this %{resource} from being saved:"
+ confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one"
devise:
failure:
@@ -17,6 +18,7 @@ en:
unauthenticated: 'You need to sign in or sign up before continuing.'
unconfirmed: 'You have to confirm your account before continuing.'
locked: 'Your account is locked.'
+ not_found_in_database: 'Invalid email or password.'
invalid: 'Invalid email or password.'
invalid_token: 'Invalid authentication token.'
timeout: 'Your session expired, please sign in again to continue.'
View
11 db/seeds.rb
@@ -5,9 +5,8 @@
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
-puts 'SETTING UP DEFAULT USER LOGIN'
-user = User.create! :name => 'First User', :email => 'user@example.com', :password => 'changeme', :password_confirmation => 'changeme'
-puts 'New user created: ' << user.name
-user2 = User.create! :name => 'Second User', :email => 'user2@example.com', :password => 'changeme', :password_confirmation => 'changeme
-'
-puts 'New user created: ' << user2.name
+# Environment variables (ENV['...']) are set in the file config/application.yml.
+# See http://railsapps.github.com/rails-environment-variables.html
+puts 'DEFAULT USERS'
+user = User.find_or_create_by_email :name => ENV['ADMIN_NAME'].dup, :email => ENV['ADMIN_EMAIL'].dup, :password => ENV['ADMIN_PASSWORD'].dup, :password_confirmation => ENV['ADMIN_PASSWORD'].dup
+puts 'user: ' << user.name
View
2  public/humans.txt
@@ -17,4 +17,4 @@
Software: Ruby on Rails
/* GENERATED BY */
- RailsApps application template: http://railsapps.github.com/
+RailsApps application template: http://railsapps.github.com/
View
4 public/robots.txt
@@ -1,5 +1,5 @@
# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
#
# To ban all spiders from the entire site uncomment the next two lines:
-User-Agent: *
-Disallow: /
+# User-Agent: *
+# Disallow: /
Please sign in to comment.
Something went wrong with that request. Please try again.