Q:

Rails Devise: two different after_update_path_for

I have two pages rendering the update user form of Devise. The classic one (users/edit) and a '/page' page with just a part of the full edit form. I would like to have two different after_update_path whether the form is submited to one or the other page. I tried several things but I none are working...
def after_update_path_for(resource)
    if current_page?('/page')
      :page
    else
      :root_path
    end
  end

I get the following error:

undefined method `current_page?' for  #RegistrationsController:0x007fe9db304e28 Did you mean? current_user

Any idea if it's possible to do that?

A:

Looks like you need to include ActionView::Helpers::UrlHelper, as the method is undefined in that controller.
class Users::RegistrationsController < Devise::SessionsController
  include ActionView::Helpers::UrlHelper

  def after_update_path_for(resource)
    if current_page?( '/path' )
      render :page
    else
      render :root_path
    end
  end
end

Here's the docs for the method. Note the comment above:

The default url to be used after updating a resource. You need to overwrite this method in your own RegistrationsController.

If for some reason this doesn't work in rails 3, you could try to do something like this:
def after_update_path_for(resource)
  if params[:action] == 'my_action' && params[:controller] == 'my_controller'
    render :page
  else
    render :root_path
  end
end

