[devise] change redirect path after account confirmation

3,361 views
Skip to first unread message

GoNZoYuMo

unread,
Apr 29, 2010, 6:11:31 PM4/29/10
to Devise
Hi,
I would appreciate your help to find a way to achieve this :

Using the "confirmable" module, I would like to redirect the user to a
particular page (some further registration steps)

Should I redefine entirely the ConfirmationController in my app just
to override the "sign_in_and_redirect" call or am I missing something
easier ?


I'm using Devise 1.0.6 with Rails 2.3.5

thanks.

Diego Plentz

unread,
Apr 29, 2010, 6:44:30 PM4/29/10
to plataforma...@googlegroups.com
You can override the method after_sign_in_path_for in your ApplicationController.
--
http://plentz.org
http://twitter.com/plentz

GoNZoYuMo

unread,
Apr 30, 2010, 5:17:34 AM4/30/10
to Devise
Oh yes,
I looked at this in the wiki but didn't thought to test controller and
action in it :/

I do this way :

if resource.is_a?(User) && params[:controller] == "confirmations" &&
params[:action] == "show"
my_new_url
else
super
end


thanks ;)

bram...@gmail.com

unread,
Jun 20, 2010, 3:21:06 AM6/20/10
to Devise
Do we need to override after_sign_up_path_for or
after_sign_in_path_for method??

I think we have to override after_sign_up_path_for? Please let me know
if I am wrong.

and I am trying with 'after_sign_up_path_for' and its NOT working.
Please suggest the solution for this..

Thanks,
Ramu.

Leroy

unread,
Jun 22, 2010, 10:48:18 AM6/22/10
to Devise
I'm having the same problem.
Can anyone help?

Walter Lee Davis

unread,
Jun 22, 2010, 10:57:10 AM6/22/10
to plataforma...@googlegroups.com
I tried using that hook, but in the end, I did the following in Rails
2.3.5 (you don't mention if you're on edge or not).

In Application Controller:

def stored_location_for( resource )
if current_user
if current_user.sign_in_count <= 1
UserMailer.deliver_first_visit(current_user)
elsif ( current_user.first_name.blank? ||
current_user.last_name.blank? || current_user.phone.blank? ||
current_user.company_name.blank? )
set_flash_message :notice, 'Please update your profile'
return '/users/' + current_user.id.to_s + '/edit'
end
end
super( resource )
end

In my workflow, I am using devise_invitable to send invitations, and
each time an invitation is accepted, the person who did the inviting
(an admin in my workflow) gets a message back saying that the person
has accepted the invitation. So that's the first login part. Then the
next time they log in, I bug them to update their profile with more
information that the inviter didn't enter.

Walter

Igor Leroy

unread,
Jun 22, 2010, 11:24:18 AM6/22/10
to plataforma...@googlegroups.com
Well... I'm trying this way:
I am using state machine for the user to only be active after you edit your password via an action that I created or use the reset_password_path.


def activate_user!
    if current_user.enabled
      true
    else
      flash[:error] = I18n.t("interface.first_password")
      current_user.reset_password_token = Devise.friendly_token
      current_user.save
      redirect_to edit_password_path(current_user, :reset_password_token => current_user.reset_password_token)
    end
  end
But enters an infinite loop =/
--
-- Igor P. Leroy

-- #!/env/ruby
-- http://twitter.com/__leroy
-- linux user #510451

Walter Lee Davis

unread,
Jun 22, 2010, 11:31:43 AM6/22/10
to plataforma...@googlegroups.com
I guess the thing to do is trace when and where activate_user! is
called, right? Try putting a logger call in there, or run it in debug
and step through that event. My guess is that it is being called by
the redirect somehow, that's the only opportunity I see for a loop.
Does current_user try to redirect to the activate?

Walter

Igor Leroy

unread,
Jun 22, 2010, 11:42:55 AM6/22/10
to plataforma...@googlegroups.com
I have not found the error, but the console or the ruby-debug show that application_controller is called again when I redirects.

Igor Leroy

unread,
Jun 22, 2010, 2:23:39 PM6/22/10
to plataforma...@googlegroups.com
Solution:
skip_before_filter

=)

marcamillion

unread,
May 7, 2013, 1:20:24 PM5/7/13
to plataforma...@googlegroups.com
Was a solution for this ever found?

I tried many of the suggestions here - and they don't work for me.

Specifically, here are more details about what I have done and what's not working - http://stackoverflow.com/questions/16415110/overriding-redirect-path-after-user-has-confirmed-account-devise
Reply all
Reply to author
Forward
0 new messages