DEV Community

Brittany
Brittany

Posted on

Day 71 : #100DaysofCode - Re-route rails app after log in with devise

Today I started working on the photo application that I plan to build.

Feel free to checkout what I got so far by visiting the repo, forking, runningbundle install, then rails s! (WARNING! It does not contain much as of yet)

README

rails db:drop rails db:create rails db:migrate rails db:migrate:status

Google:rails console not working https://stackoverflow.com/questions/24276033/rails-console-doesnt-start spring stop rails console

I want to create a simple rails app that will allow users to:

  1. Search for images to add to their page - sers can have a profile picture (active storage)
  2. Follow eachother
  3. Add pictures from other pages to their own.

First create users and Devise gem Cancancan Users can follow eachother Users can add photos to their page Users can search for photos Users can sign in using google, twitter, or github https://source.unsplash.com/1600x900/?nature,water Inspirational quote with photo?

#rails g resource User name:string #rails g resource Follow follower_id:integer followee_id:integer

photo-app

Steps taken to build:

  1. rails new photo_app --database=postgresql
  2. cd photo_app
  3. rails g resource User name:string
  4. rails g resource Follow follower_id:integer followee_id:integer
  5. rake db:drop db:create db:migrate

rails d resource User name:string rails d resource Follow

  1. gem 'devise'
  2. rails generate devise:install
  3. rails generate devise User

Something that I had to search for as I set up my users with devise is how to stop it from automatically re-routing to my root page. A google search showed me that if I added the following code to my application controller that I could stop it from doing that:

  def after_sign_in_path_for(resource)
        profile_path(current_user) 
    end
Enter fullscreen mode Exit fullscreen mode

And it worked! One barrier down, more to come!

Tomorrow I will try to figure out where to put an API_Manager on a rails application and hopefully get it to show on my photos index page the way I would like it do. Where should I put my API managers? Does it go in my helpers? Does it have its own controller?

So much research ahead of me, I can not wait.

Until tomorrow!

Sincerely,
Brittany

Song of the day:

Top comments (0)