DEV Community


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)


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

Google:rails console not working 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,water Inspirational quote with photo?

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


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)
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!


Song of the day:

Top comments (0)