1. Initial installation and set up a basic home page - verachell/Simple-rails-tryout-app-using-devise GitHub Wiki

Sources and background reading

Here is where I got info for this project. The best source for how to install devise is from:

Additionally, I also found this tutorial helpful:

Getting started with a new rails app

Before installing devise, start a new rails app as follows:

rails new tryoutdevise
cd tryoutdevise
bin/rails generate controller Homepages index --skip-routes

in config/routes.rb, put root to: "homepages#index"

This gives us a static homepage to work with

Feel free to change the look of your homepage in app/views/homepages/index.html.erb

As always after making changes, check that your app looks and works as expected by going to the working directory and in the command line typing bin/rails server and then navigating to localhost:3000 in your browser

Add the devise gem

In the Gemfile, add

gem "devise"

then in terminal do

bundle install

then

rails generate devise:install

There will be some output, it will look something like this:

     create  config/initializers/devise.rb
      create  config/locales/devise.en.yml
===============================================================================

Depending on your application's configuration some manual setup may be required:

  1. Ensure you have defined default url options in your environments files. Here
     is an example of default_url_options appropriate for a development environment
     in config/environments/development.rb:

       config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }

     In production, :host should be set to the actual host of your application.

     * Required for all applications. *

  2. Ensure you have defined root_url to *something* in your config/routes.rb.
     For example:

       root to: "home#index"
     
     * Not required for API-only Applications *

  3. Ensure you have flash messages in app/views/layouts/application.html.erb.
     For example:

       <p class="notice"><%= notice %></p>
       <p class="alert"><%= alert %></p>

     * Not required for API-only Applications *

  4. You can copy Devise views (for customization) to your app by running:

       rails g devise:views
       
     * Not required *

===============================================================================

Next - inspect the new files generated. Start with /config/initializers/devise.rb

As you can see, there are lots and lots of options. For now, leave the file as is but we'll come back to that later.

The other file, config/locales/devise.en.yml has the (English) translations for all the various phrases.

As mentioned in the output above, you may wish to add flash messages in app/views/layouts/application.html.erb You can place it in body section before yield:

    <p class="notice"><%= notice %></p>
    <p class="alert"><%= alert %></p>

Ultimately I didn't leave mine in that location and ultimately put them elsewhere (documented further along) but you probably want to have these flash messages somewhere in your views

⚠️ **GitHub.com Fallback** ⚠️