You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This work is a compilation and derivation from other previously released works. With the exception of various included works, which may be restricted by other licenses, the author or authors of this code dedicate any and all copyright interest in this code to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this code under copyright law.
Copy file name to clipboardExpand all lines: README.textile
+55-93
Original file line number
Diff line number
Diff line change
@@ -8,26 +8,26 @@ Rails 3.2 example application shows how to use "Devise":http://github.com/plataf
8
8
9
9
Best of all, there's a "detailed tutorial":http://railsapps.github.com/tutorial-rails-devise-rspec-cucumber.html to show how it's built.
10
10
11
-
You can clone this app or generate a new Rails application using an "application template":https://github.com/RailsApps/rails3-application-templates.
11
+
You can build this application in only a few minutes using the "Rails Composer":http://railsapps.github.com/rails-composer/ tool.
12
12
13
13
h2. !http://twitter-badges.s3.amazonaws.com/t_logo-a.png(Follow on Twitter)!:http://www.twitter.com/rails_apps Follow on Twitter
14
14
15
15
Follow the project on Twitter: "@rails_apps":http://twitter.com/rails_apps. Please tweet some praise if you like what you've found.
16
16
17
17
h2. Tutorial
18
18
19
-
A complete walkthrough tutorial is available on the GitHub wiki:
19
+
A complete tutorial is available:
20
20
21
21
h4. "View the Tutorial":http://railsapps.github.com/tutorial-rails-devise-rspec-cucumber.html
22
22
23
23
The tutorial documents each step to follow to create the application. Every step is documented concisely, so a complete beginner can create this application without any additional knowledge. However, no explanation is offered for any of the steps, so if you are a beginner, you’re advised to look for an introduction to Rails elsewhere. See a list of recommended resources for "Rails":http://railsapps.github.com/rails.html.
24
24
25
-
If you simply wish to modify the application for your own project, you can download the application and set it up as described below, without following the tutorial.
26
-
27
25
h2. What Is Implemented -- and What Is Not
28
26
29
27
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.
30
28
29
+
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.
30
+
31
31
h4. Similar Examples and Tutorials
32
32
33
33
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.
@@ -45,124 +45,80 @@ Before generating your application, you will need:
45
45
* The Ruby language (version 1.9.3)
46
46
* Rails 3.2
47
47
48
-
See "Installing Rails 3.2":http://railsapps.github.com/installing-rails.html for detailed instructions and advice.
48
+
See the article "Installing Rails":http://railsapps.github.com/installing-rails.html for advice about updating Rails and your development environment.
49
49
50
50
h2. Getting the Application
51
51
52
52
You have several options for getting the code.
53
53
54
-
h4. Fork, Clone, or Generate?
55
-
56
-
_Fork:_ If you'd like to add features (or bug fixes) to improve the example application, you can fork the GitHub repo and "make pull requests":http://help.github.com/send-pull-requests/. Your code contributions are welcome!
57
-
58
-
_Clone:_ If you want to copy and customize the app with changes that are only useful for your own project, you can clone the GitHub repo. You'll need to search-and-replace the project name throughout the application. You probably should generate the app instead (see below).
54
+
h3. Fork
59
55
60
-
_Generate:_ If you want to use the project as a starter app for your customized application, use the application template to generate a new version of the example app. You'll be able to give it your own project name when you generate the app. Generating the application (described below) gives you many options, such as using Haml for views, additional Devise modules, and various HTML5/CSS front-end frameworks such as Twitter Bootstrap.
56
+
If you'd like to add features (or bug fixes) to improve the example application, you can fork the GitHub repo and "make pull requests":http://help.github.com/send-pull-requests/. Your code contributions are welcome!
61
57
62
-
h4. Clone the Repository
58
+
h3. Clone
63
59
64
-
If you simply wish to examine the example code, you can download the code ("clone the repository") with the command
60
+
If you want to copy and customize the app with changes that are only useful for your own project, you can clone the GitHub repo. You'll need to search-and-replace the project name throughout the application. You probably should generate the app instead (see below). To clone:
The source code is managed with Git (a version control system). You'll need Git on your machine (install it from "http://git-scm.com/":http://git-scm.com/).
66
+
You'll need "git":http://git-scm.com/ on your machine. See "Rails and Git":http://railsapps.github.com/rails-git.html.
71
67
72
-
h4. Using the Ready-Made Application Template
68
+
h3. Generate
73
69
74
-
You can use an application template to generate a new version of the example app. You’ll find an application template for this app in the "Rails Application Templates":https://github.com/RailsApps/rails3-application-templates repository.
70
+
If you want to use the project as a starter app, use the "Rails Composer":http://railsapps.github.com/rails-composer/ tool to generate a new version of the example app. You'll be able to give it your own project name when you generate the app. Generating the application gives you many additional options.
75
71
76
-
To build the "rails3-devise-rspec-cucumber" example application, run the command:
72
+
To build the example application, run the command:
77
73
78
74
<pre>
79
-
$ rails new myapp -m https://github.com/RailsApps/rails3-application-templates/raw/master/rails3-devise-rspec-cucumber-template.rb -T
75
+
$ rails new myapp -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb -T
80
76
</pre>
81
77
82
78
Use the @-T@ flag to skip Test::Unit files.
83
79
84
80
The @$@ character indicates a shell prompt; don't include it when you run the command.
85
81
86
-
This creates a new Rails app (with the name @myapp@) on your computer.
87
-
88
-
The application generator templates will ask you for various preferences.
89
-
90
-
To reproduce the example application exactly as found in the repository, make the following selections:
91
-
92
-
* Would you like to use "Haml":http://en.wikipedia.org/wiki/Haml instead of ERB? *no*
93
-
* Would you like to use "RSpec":http://rspec.info/ instead of TestUnit? *yes*
94
-
* Would you like to use "factory_girl":https://github.com/thoughtbot/factory_girl for test fixtures with RSpec? *yes*
95
-
* Would you like to use "machinist":https://github.com/notahat/machinist for test fixtures with RSpec? *no*
96
-
* Would you like to use "Cucumber":http://cukes.info/ for your BDD? *yes*
97
-
* Would you like to use "Guard":http://intridea.com/posts/hire-a-guard-for-your-project to automate your workflow? *no*
98
-
* Would you like the app to use a Gmail account to send email? *yes*
99
-
* Would you like to use "Devise":http://github.com/plataformatec/devise for authentication?
100
-
## No
101
-
## Devise with default modules *#2*
102
-
## Devise with Confirmable module
103
-
## Devise with Confirmable and Invitable modules
104
-
* Would you like to manage authorization with CanCan & Rolify? *no*
105
-
* Which front-end framework would you like for HTML5 and CSS3?
* Would you like to use "rails-footnotes":https://github.com/josevalim/rails-footnotes during development? *no*
117
-
* Would you like to set a robots.txt file to ban spiders? *yes*
118
-
* Would you like to add 'will_paginate' for pagination? *no*
119
-
* Add 'therubyracer' JavaScript runtime (for Linux users without node.js)? *no*
120
-
121
-
You can choose other selections if you don't care about matching the example application exactly.
122
-
123
-
h4. Use "Recipes" to Customize an Application Template
124
-
125
-
The application template was created using the "rails_apps_composer":https://github.com/RailsApps/rails_apps_composer gem which provides a convenient way to assemble a reusable application template by selecting various "recipes" for popular Rails development packages. Use "rails_apps_composer":https://github.com/RailsApps/rails_apps_composer if you want to customize the application template for your own starter apps.
126
-
127
-
h4. Edit the README
128
-
129
-
If you're open sourcing the app on GitHub, please edit the README file to add a description of the app and your contact info. Changing the README is important if you're using a clone of the example app. I've been mistaken (and contacted) as the author of apps that are copied from my example.
82
+
This creates a new Rails app (with the name "myapp") on your computer.
130
83
131
-
h2. Getting Started
84
+
h3. Edit the README
132
85
133
-
h4. About Required Gems
86
+
If you're storing the app in a GitHub repository, please edit the README files to add a description of the app and your contact info. If you don't change the README, people will think I am the author of your version of the application.
See "Example Gemfiles for Rails 3.2":http://railsapps.github.com/rails-3-2-example-gemfile.html.
92
+
Check the Gemfile to see which gems are used by this application.
146
93
147
-
h4. Install the Required Gems
94
+
If you used the "Rails Composer":http://railsapps.github.com/rails-composer/ tool to generate the example app, the application template script has already run the @bundle install@ command.
148
95
149
-
Install the required gems on your computer:
96
+
If not, you should run the @bundle install@ command to install the required gems on your computer:
150
97
151
-
@$ bundle install@
98
+
<pre>
99
+
$ bundle install
100
+
</pre>
152
101
153
102
You can check which gems are installed on your computer with:
154
103
155
-
@$ gem list --local@
104
+
<pre>
105
+
$ gem list
106
+
</pre>
156
107
157
108
Keep in mind that you have installed these gems locally. When you deploy the app to another server, the same gems (and versions) must be available.
158
109
159
-
h2. Configure Email
110
+
I recommend using "rvm":https://rvm.io/, the Ruby Version Manager, to create a project-specific gemset for the application. See the article "Installing Rails":http://railsapps.github.com/installing-rails.html.
160
111
161
-
You must configure the app for your email account if you want your application to send email messages, for example, if you've generated the application with the option to install the Devise @:confirmable@ module.
112
+
h3. Configure Email
113
+
114
+
You must configure the app for your email account if you want your application to send email messages.
162
115
163
116
h4. Use a Gmail account
164
117
165
-
If you've generated the application with the option to use a Gmail account to send email, you'll need to modify the files *config/environments/development.rb* and *config/environments/production.rb* to include your Gmail username and password.
118
+
You'll need to modify two files to include your Gmail username and password:
119
+
120
+
* *config/environments/development.rb*
121
+
* *config/environments/production.rb*
166
122
167
123
<pre>
168
124
config.action_mailer.smtp_settings = {
@@ -191,29 +147,32 @@ Open a new shell or restart your terminal application to continue.
191
147
192
148
h4. Configure ActionMailer
193
149
194
-
The example application is set to deliver email in both development and production. It will raise delivery errors in development but not production.
150
+
The example application is set to deliver email in production only. It will raise delivery errors in development but not production.
195
151
196
152
In development, @config.action_mailer.default_url_options@ is set for a host at @localhost:3000@ which will enable links in Devise confirmation email messages to work properly. You'll need to change the @config.action_mailer.default_url_options@ host option from @example.com@ to your own domain for the production environment.
197
153
198
-
You can change these values as needed in the *config/environments/development.rb* and *config/environments/production.rb* files.
154
+
You can change these values as needed in these two files:
155
+
156
+
* *config/environments/development.rb*
157
+
* *config/environments/production.rb*
199
158
200
159
h4. Configure Devise for Email
201
160
202
161
Complete your email configuration by modifying
203
162
204
-
*config/initializers/devise.rb*
163
+
* *config/initializers/devise.rb*
205
164
206
165
and setting the @config.mailer_sender@ option for the return email address for messages that Devise sends from the application.
207
166
208
167
h2. Configure Devise
209
168
210
169
You can modify the configuration file for Devise if you want to use something other than the defaults:
211
170
212
-
*config/initializers/devise.rb*
171
+
* *config/initializers/devise.rb*
213
172
214
173
h2. Create a Default User
215
174
216
-
h4. Set Up a Database Seed File
175
+
h3. Set Up a Database Seed File
217
176
218
177
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:
Use the defaults or change the values for name, email, and password as you wish.
229
189
230
-
If you've generated the application with the option to install the Devise @:confirmable@ module, there will be an extra attribute @confirmed_at => Time.now@ for creation of a user.
231
-
232
-
h4. Set the Database
190
+
h3. Set the Database
233
191
234
192
Prepare the database and add the default user to the database by running the commands:
235
193
236
194
<pre>
237
-
$ bundle exec rake db:migrate
238
-
$ bundle exec rake db:seed
195
+
$ rake db:migrate
196
+
$ rake db:seed
239
197
</pre>
240
198
241
199
Set the database for running tests:
242
200
243
201
<pre>
244
-
$ bundle exec rake db:test:prepare
202
+
$ rake db:test:prepare
245
203
</pre>
246
204
205
+
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.
206
+
247
207
h2. Test the App
248
208
249
209
You can check that your app runs properly by entering the command
@@ -259,6 +219,8 @@ To sign in as the default user, (unless you've changed it) use
259
219
260
220
You should delete or change the pre-configured logins before you deploy your application.
261
221
222
+
If you test the app by starting the web server and then leave the server running while you install new gems, you’ll have to restart the server to see any changes. The same is true for changes to configuration files in the config folder. This can be confusing to new Rails developers because you can change files in the app folders without restarting the server. Stop the server each time after testing and you will avoid this issue.
223
+
262
224
h2. Deploy to Heroku
263
225
264
226
For your convenience, here is a "Tutorial for Rails on Heroku":http://railsapps.github.com/rails-heroku-tutorial.html. Heroku provides low cost, easily configured Rails application hosting.
@@ -291,7 +253,7 @@ Are you getting an error "OpenSSL certificate verify failed" when you try to gen
291
253
292
254
h2. Documentation and Support
293
255
294
-
This is the only documentation.
256
+
The "tutorial":http://railsapps.github.com/tutorial-rails-devise-rspec-cucumber.html provides additional documentation.
295
257
296
258
For a Devise introduction, Ryan Bates offers a "Railscast on Devise":http://railscasts.com/episodes/209-introducing-devise. You can find documentation for "Devise":http://github.com/plataformatec/devise at "http://github.com/plataformatec/devise":http://github.com/plataformatec/devise. There is an active "Devise mailing list":http://groups.google.com/group/plataformatec-devise and you can submit "Devise issues":http://github.com/plataformatec/devise/issues at GitHub.
297
259
@@ -315,7 +277,7 @@ If you add functionality to this application, create an alternative implementati
315
277
316
278
h2. Credits
317
279
318
-
Daniel Kehoe ("http://danielkehoe.com/":http://danielkehoe.com/) implemented the application and wrote the tutorial.
280
+
Daniel Kehoe implemented the application and wrote the tutorial.
319
281
320
282
Is the app useful to you? Follow the project on Twitter: "@rails_apps":http://twitter.com/rails_apps
321
283
and tweet some praise. I'd love to know you were helped out by what I've put together.
0 commit comments