Sam Mason
Sam Mason

Reputation: 1037

How to create a session#show when using Devise to create a Profile page

first time poster so apologies if I come across very noob like.

I have started developing a TODO Rails app that allows people to login and create several lists for themselves.

I would like to have the user flow work so that after the user signs in they are presented with a "Profile page" that shows some importent links, info on the user and then a grid containing their lists etc.

Now down to the query, What is the best way to go about this as I have a User model and also a list model. Do I need to create a profile controller that has a simple #index action on it that I can pull in info from the 2 models or is there a more acceptable way?

I was hoping that Devise would provide something like this but if they do I cant find it.

Upvotes: 1

Views: 501

Answers (1)

Jason Swett
Jason Swett

Reputation: 45164

I'm not sure that I would couple my user profile page with Devise. Devise is a tool for user authentication, and it seems to me that a user profile page isn't really related to authentication.

I would put your user profile on the user show page, i.e. app/views/user/show.html.erb. (If it doesn't already exist, you might have to create a UserController and app/views/user directory.)

As for redirecting users to the profile page on login, this is (basically) how I do it in app/controllers/application_controller.rb:

class ApplicationController < ActionController::Base
  def after_sign_in_path_for(resource_or_scope)
    user_show_path(current_user)
  end
end

To address your last question, at least partially, no, I wouldn't create a profile controller. Thinking RESTfully, a user profile page would be most appropriate, it seems to me, in UserController#show.

Upvotes: 1

Related Questions