문제

I'm actually building a system where users, after registering on my application and confirm their account by email, will be redirected to a wizard process page (build in Js) where they will be asked to fill in some more information.

To do that, I create a function in my app controller which will redirect the user to that process page, according to certain condition :

// application_controller.rb
class ApplicationController < ActionController::Base
  before_filter :fill_in_profile

  protected
    def fill_in_profile
      if user_signed_in?
        if current_user.employee? && !current_user.filled?
          redirect_to new_profile_path
        end
      end
    end
end

The problem here is that Im getting a 302 status error because it's creating an infinite redirection loop. So I wanted to know how you guys were handling those kind of page and process?

Thanks

도움이 되었습니까?

해결책

Add a skip_before_action in your ProfilesController (or wherever new_profile_path points to):

class ProfilesController
  skip_before_action :fill_in_profile

  def new
    # …
  end
end

I'd love to recommend a link into the Rails API, but neither AbstractController::Callbacks nor AbstractController::Callbacks::ClassMethods.skip_before_filter looks promising…

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top