CSC/ECE 517 Spring 2016/Refactor review mapping controller.rb: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
Devise is a rack based full-fledged authentication system for Rails. It is a complete MVC solution meaning it can support various models, views and controllers as part of its code and can be used be directly by developers. Devise is simple to use and starts up with a couple of commands but it is also highly customizable.
Devise is a rack based full-fledged authentication system for Rails. It is a complete MVC solution meaning it can support various models, views and controllers as part of its code and can be used be directly by developers. Devise is simple to use and starts up with a couple of commands but it is also highly customizable. Devise will save a lot of time and effort as many applications require user registration and authentication mechanisms which are difficult to develop from scratch.


=='''History'''==
=='''History'''==

Revision as of 21:59, 6 February 2016

Devise is a rack based full-fledged authentication system for Rails. It is a complete MVC solution meaning it can support various models, views and controllers as part of its code and can be used be directly by developers. Devise is simple to use and starts up with a couple of commands but it is also highly customizable. Devise will save a lot of time and effort as many applications require user registration and authentication mechanisms which are difficult to develop from scratch.

History

Devise is first introduced in January 2010 by Plataformatec, a company which builds web and mobile applications. Devise is one of the few authentication systems which support rack based applications and hence can support Rails 3 and up as they are completely rack based. The latest version of Devise available is v3.5.3 and it is up to date to Rails 5 beta 2.

Installation

There are several commands that are required for the successful installation of Devise. They are listed out below:

  • Add the devise gem to your gemfile.
gem 'devise'
  • Run bundle command to install the gem.
bundle install
  • You need to run the generator next which will install an initializer and creates all the configuration files.
rails generate devise:install
  • Now you can add Devise to any of your models using the generator. This will create a class with the model name given and routes etc. The model will be configured with default Devise modules. The config/routes.rb file will be configured to point to the Devise controller.
rails generate devise user //Assuming that the model name is user
  • Next, add any configuration changes that are required and then run:
rake db:migrate
  • The following step will create Devise views but is optional. Devise has views for every generic operation like Login or SignUp and can be used directly instead of creating custom views.
rails generate devise:views users

Modules

Methods

authenticate_user!

current_user

user_signed_in?

signed_in(@user)

sign_out(@user)

user_session

See Also

References

Further Reading

External Links