tutoto
tutoto

Reputation: 99

How to configure the root_path to a specific show view

Do you know how we can param the root_path to display the first Post of the current user ?

Upvotes: 1

Views: 46

Answers (1)

lili pupu
lili pupu

Reputation: 161

If you use Devise, you can use this function :

In your Application controller:

def after_sign_in_path_for(resource)
  @post = current_user.posts.first
  request.env['omniauth.origin'] || post_path(@post)
end

It's gonna redirect the user to his first post show

Upvotes: 1

Related Questions