sajad torkamani

Install gem

./bin/bundle add devise

Run installer and follow instructions

./bin/rails g devise:install

Instructions are something like:

  • Ensure config.action_mailer.default_url_options is set.
  • Ensure root_url is set in config/routes.rb.
  • Ensure flash messages are included in your application.html.erb file. For example: <% if notice %> <p class="notice"><%= notice %></p> <% end %> <% if alert %> <p class="alert"><%= alert %></p> <% end %>
  • (Optional) Copy devise views.rails g devise:views

Generate Devise model and migration

Run:

./bin/rails g devise User

If required, add any further changes to the generated model and migration files.

Run migrations

./bin/rails db:migrate

(Optional) Configure devise in RSpec

See this post.

(Optional) Configure to work with turbo-rails

At the time of writing (02/02/2021), it seems like Devise forms with turbo-rails unless you add the data-turbo=false attribute to the <form>. See this issue.

Sources

Leave a comment

Your email address will not be published. Required fields are marked *