DEV Community

Mary Webby
Mary Webby

Posted on

Bulletin Board User Auth

setting up the rails generate devise:install

rails generate devise:install
Enter fullscreen mode Exit fullscreen mode
  • paste into terminal after running rake sample_data, and bin/dev. this will generate the following
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 *
Enter fullscreen mode Exit fullscreen mode
  • We complete sets 1 through 3 for this project, but you are also allowed to complete step 4, we did not go into that.

why are we doing this

  • Before, we were creating our databases with our models and columns in psql, which is good for initially setting up our db, but say we want to add things further down the line with other columns we need to add. Here, we are using db migrate and creating migration files to be able to add more to our db.

  • So initially, we need to create the migration file, which we can do by running rails generate migration AddUserIdToBoards user_id:integer for example. This will create the migration file for us to use, which we can then run rake db:migrate to then allow our database to officially implement those changes.

  • if we were to accidentally run rake db:migrate, we would run into the issue of having the database already initialized, and would have to start over again, which is what i was stating previously in the section above.

Top comments (0)