<commit_before>h1. !http://railsapps.github.io/images/rails-36x36.jpg(Rails Devise Pundit)! Rails Devise Pundit

Rails 4.1 example application that provides user management, authentication, and authorization. The application shows how to integrate:

* "Devise":https://github.com/plataformatec/devise for user management and authentication
* "Pundit":https://github.com/elabs/pundit for authorization
* "Bootstrap":http://getbootstrap.com/ or "Foundation":http://foundation.zurb.com/ front-end frameworks

Use this example application as a starter app for your own web applications.

You can build this application in only a few minutes using the "Rails Composer":http://railsapps.github.io/rails-composer/ tool, choosing either a Bootstrap or Foundation front-end framework, as well as many other options, such as Haml or Slim.

h4. !http://railsapps.github.io/images/join/join-railsapps.png(Join RailsApps)!:http://railsapps.github.io/

h4. What is the RailsApps Project?

The "RailsApps project":http://railsapps.github.io/ provides example applications that developers use as starter apps. Hundreds of developers use the apps, report problems as they arise, and propose solutions. Rails changes frequently; each application is known to work and serves as your personal "reference implementation." Support for the project comes from subscribers. If this application is helpful to you, please "join the RailsApps project":http://railsapps.github.io/ to support our work.

h4. If You Are New to Rails

If you're new to Rails, see "What is Ruby on Rails?":http://railsapps.github.io/what-is-ruby-rails.html, the book "Learn Ruby on Rails":http://learn-rails.com/learn-ruby-on-rails.html, and recommendations for a "Rails tutorial":https://tutorials.railsapps.org/rails-tutorial.

h2. What Is Implemented -- and What Is Not

This application extends the "rails-devise":https://github.com/RailsApps/rails-devise example application to add authorization with Pundit. The "rails-devise":https://github.com/RailsApps/rails-devise example application provides:

* Home page
* Navigation bar
* Sign up (create account)
* Login
* "Forgot password?" feature
* "Remember me" (stay logged in) feature
* Edit account (edit user profile)
* List of users

This application adds authorization with Pundit, showing how to implement user roles, and limit access to pages based on user role. With this application:

* an admin can see a list of users
* an admin can change a user's role
* an ordinary user can't see a list of users
* an ordinary user can't change their role
* an ordinary user can't see (or edit) another user's profile
* an ordinary user can see (and edit) their own user profile

After examining the example application, you'll be able to implement access control in your own applications.

h4. Database

The application requires a database. The example application uses SQLite with Rails ActiveRecord. You can easily substitute PostgreSQL, MySQL, or other databases.

h4. Front-end Framework

The example application (here in the GitHub repository) includes simple CSS for a navigation bar and flash messages. The "rails_layout":https://github.com/RailsApps/rails_layout gem is included so you can add the Bootstrap or Foundation front-end frameworks.

h2. Similar Examples and Tutorials

This is one in a series of Rails example apps and tutorials from the "RailsApps Project":http://railsapps.github.io/. See a list of additional "Rails examples, tutorials, and starter apps":http://railsapps.github.io/rails-examples-tutorials.html. Related example applications may be useful:

* "Learn Rails":https://github.com/RailsApps/learn-rails companion to the book "Learn Ruby on Rails":http://learn-rails.com/learn-ruby-on-rails.html
* "Foundation and Rails":http://railsapps.github.io/rails-foundation/ shows how to integrate Foundation
* "Bootstrap and Rails":http://railsapps.github.io/rails-bootstrap/ shows to integrate Bootstrap
* "OmniAuth and Rails":https://github.com/RailsApps/rails-omniauth uses OmniAuth for authentication
* "Devise and Rails":https://github.com/RailsApps/rails-devise uses Devise for authentication

h2. Accounts You Will Need

Devise provides a "Forgot Password?" feature that resets a password and sends instructions to the user. You'll need an email service provider to send email from the application. You can use "Gmail":https://accounts.google.com/SignUp?service=mail during development. You can get a free "Gmail":https://accounts.google.com/SignUp?service=mail account if you don't already have one. For production, Gmail is not robust. Use transactional email services, such as "Mandrill":http://mandrill.com/, to send email in production. See the article "Send Email with Rails":http://railsapps.github.io/rails-send-email.html for more information.

We provide instructions to deploy the application to "Heroku":https://www.heroku.com/ which provides Rails application hosting. It costs nothing to set up a Heroku account and deploy as many applications as you want. To deploy an app to Heroku, you must have a Heroku account. Visit Heroku "to set up an account":https://id.heroku.com/signup/devcenter.

h2. Dependencies

Before generating your application, you will need:

* The Ruby language - version 2.1
* The Rails gem - version 4.1

See the article "Installing Rails":http://railsapps.github.io/installing-rails.html for instructions about setting up Rails and your development environment.

h2. Getting the Application

You have several options for getting the code. You can _fork_, _clone_, or _generate_.

h3. 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!

h3. 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). To clone:

<pre>
$ git clone git://github.com/RailsApps/rails-devise-pundit.git
</pre>

You'll need "git":http://git-scm.com/ on your machine. See "Rails and Git":http://railsapps.github.io/rails-git.html.

h3. Generate

If you want to use the project as a starter application, use the "Rails Composer":http://railsapps.github.io/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 additional options.

To build the example application, Rails 4.1 must be installed in your development environment. Run the command:

<pre>
$ rails new rails-devise-pundit -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb
</pre>

The @$@ character indicates a shell prompt; don't include it when you run the command.

This creates a new Rails app named @rails-devise-pundit@ on your computer. You can use a different name if you wish.<commit_msg>add link to 'Hack on Nitrous'<commit_after>h1. !http://railsapps.github.io/images/rails-36x36.jpg(Rails Devise Pundit)! Rails Devise Pundit

Rails 4.1 example application that provides user management, authentication, and authorization. The application shows how to integrate:

* "Devise":https://github.com/plataformatec/devise for user management and authentication
* "Pundit":https://github.com/elabs/pundit for authorization
* "Bootstrap":http://getbootstrap.com/ or "Foundation":http://foundation.zurb.com/ front-end frameworks

Use this example application as a starter app for your own web applications.

You can build this application in only a few minutes using the "Rails Composer":http://railsapps.github.io/rails-composer/ tool, choosing either a Bootstrap or Foundation front-end framework, as well as many other options, such as Haml or Slim.

h4. !http://railsapps.github.io/images/join/join-railsapps.png(Join RailsApps)!:http://railsapps.github.io/

h4. What is the RailsApps Project?

The "RailsApps project":http://railsapps.github.io/ provides example applications that developers use as starter apps. Hundreds of developers use the apps, report problems as they arise, and propose solutions. Rails changes frequently; each application is known to work and serves as your personal "reference implementation." Support for the project comes from subscribers. If this application is helpful to you, please "join the RailsApps project":http://railsapps.github.io/ to support our work.

h4. If You Are New to Rails

If you're new to Rails, see "What is Ruby on Rails?":http://railsapps.github.io/what-is-ruby-rails.html, the book "Learn Ruby on Rails":http://learn-rails.com/learn-ruby-on-rails.html, and recommendations for a "Rails tutorial":https://tutorials.railsapps.org/rails-tutorial.

h2. What Is Implemented -- and What Is Not

This application extends the "rails-devise":https://github.com/RailsApps/rails-devise example application to add authorization with Pundit. The "rails-devise":https://github.com/RailsApps/rails-devise example application provides:

* Home page
* Navigation bar
* Sign up (create account)
* Login
* "Forgot password?" feature
* "Remember me" (stay logged in) feature
* Edit account (edit user profile)
* List of users

This application adds authorization with Pundit, showing how to implement user roles, and limit access to pages based on user role. With this application:

* an admin can see a list of users
* an admin can change a user's role
* an ordinary user can't see a list of users
* an ordinary user can't change their role
* an ordinary user can't see (or edit) another user's profile
* an ordinary user can see (and edit) their own user profile

After examining the example application, you'll be able to implement access control in your own applications.

h4. Database

The application requires a database. The example application uses SQLite with Rails ActiveRecord. You can easily substitute PostgreSQL, MySQL, or other databases.

h4. Front-end Framework

The example application (here in the GitHub repository) includes simple CSS for a navigation bar and flash messages. The "rails_layout":https://github.com/RailsApps/rails_layout gem is included so you can add the Bootstrap or Foundation front-end frameworks.

h2. Similar Examples and Tutorials

This is one in a series of Rails example apps and tutorials from the "RailsApps Project":http://railsapps.github.io/. See a list of additional "Rails examples, tutorials, and starter apps":http://railsapps.github.io/rails-examples-tutorials.html. Related example applications may be useful:

* "Learn Rails":https://github.com/RailsApps/learn-rails companion to the book "Learn Ruby on Rails":http://learn-rails.com/learn-ruby-on-rails.html
* "Foundation and Rails":http://railsapps.github.io/rails-foundation/ shows how to integrate Foundation
* "Bootstrap and Rails":http://railsapps.github.io/rails-bootstrap/ shows to integrate Bootstrap
* "OmniAuth and Rails":https://github.com/RailsApps/rails-omniauth uses OmniAuth for authentication
* "Devise and Rails":https://github.com/RailsApps/rails-devise uses Devise for authentication

h2. Accounts You Will Need

Devise provides a "Forgot Password?" feature that resets a password and sends instructions to the user. You'll need an email service provider to send email from the application. You can use "Gmail":https://accounts.google.com/SignUp?service=mail during development. You can get a free "Gmail":https://accounts.google.com/SignUp?service=mail account if you don't already have one. For production, Gmail is not robust. Use transactional email services, such as "Mandrill":http://mandrill.com/, to send email in production. See the article "Send Email with Rails":http://railsapps.github.io/rails-send-email.html for more information.

We provide instructions to deploy the application to "Heroku":https://www.heroku.com/ which provides Rails application hosting. It costs nothing to set up a Heroku account and deploy as many applications as you want. To deploy an app to Heroku, you must have a Heroku account. Visit Heroku "to set up an account":https://id.heroku.com/signup/devcenter.

h2. Dependencies

Before generating your application, you will need:

* The Ruby language - version 2.1
* The Rails gem - version 4.1

See the article "Installing Rails":http://railsapps.github.io/installing-rails.html for instructions about setting up Rails and your development environment.

h2. Getting the Application

h3. Cloud

Click the button below to install the app on "Nitrous.io":https://www.nitrous.io/, a hosted development environment. Nitrous.io is free for small projects. See "Ruby on Rails with Nitrous.io":http://railsapps.github.io/rubyonrails-nitrous-io.html for more information.

"!https://d3o0mnbgv6k92a.cloudfront.net/assets/hack-l-v1-3cc067e71372f6045e1949af9d96095b.png(Hack RailsApps on Nitrous.IO)!":https://www.nitrous.io/hack_button?source=embed&runtime=rails&repo=RailsApps%2Frails-devise-pundit&file_to_open=nitrous.txt

h3. Local

You have several options for getting the code on your own machine. You can _fork_, _clone_, or _generate_.

h4. 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!

h4. 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). To clone:

<pre>
$ git clone git://github.com/RailsApps/rails-devise-pundit.git
</pre>

You'll need "git":http://git-scm.com/ on your machine. See "Rails and Git":http://railsapps.github.io/rails-git.html.

h4. Generate

If you want to use the project as a starter application, use the "Rails Composer":http://railsapps.github.io/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 additional options.

To build the example application, Rails 4.1 must be installed in your development environment. Run the command:

<pre>
$ rails new rails-devise-pundit -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb
</pre>

The @$@ character indicates a shell prompt; don't include it when you run the command.

This creates a new Rails app named @rails-devise-pundit@ on your computer. You can use a different name if you wish.
{'fraction_non_alphanumeric': 0.08528508023216115, 'fraction_numerical': 0.0057357459883919425, 'mean_word_length': 4.674544750096862, 'pattern_counts': {'":': 67, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 31, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3895444', 'n_tokens_mistral': 4259, 'n_tokens_neox': 3948, 'n_words': 1749}