2012-08-09 4 views
2

나는 내 웹 사이트에 사용자 등록 뷰와 모델을 만들기 위해 노력하고 있지만 작은 문제가 오전 : 페이스 북의 작동 기능을 연결 얻기 위해 내가 고안 사용하고고안와 페이스 북 사용자 정의 라우팅

및 omniauth을하고 그것을 작동 , 하지만 처음 페이스 북 사용자가 비밀번호를 만들 때 로그인을 원합니다. 그럴 수도 있습니다. 채워진 가입 양식으로 리디렉션되며 비밀번호 만 입력하면됩니다. 그러나 나는 그들에게 암호를 입력 할 수있는 /views/registrations/new_facebook.html.erb라는 두 번째 "sign_up 형식"으로 이동하기를 원합니다.

올바른보기를 만들었고 그것을 테스트하지만 얼마나 큰이 될 것이라고 누군가가 나를 도울 수 있다면 고안 기본에게 내가 그 인식되지 무슨 때문에 문제가 경기를 함께 생각

match '/facebook' => 'registrations#new', :as => 'new_facebook_user_registration' 

,

을 우회 할 수있는 올바른 경로를 만드는 아무 생각이 없다 감사,

가 어떻게이 redirect_to의 new_facebook_user_registration_url가 실제로 작동 할 수

class OmniauthCallbacksController < Devise::OmniauthCallbacksController 
def all 
user = User.from_omniauth(request.env["omniauth.auth"]) 
if user.persisted? 
     flash[:success] = "Welcome back" 
      sign_in_and_redirect user 
else 
    session["devise.user_attributes"] = user.attributes 
    redirect_to new_facebook_user_registration_url 
end 
end 
alias_method :facebook, :all 

끝 :3210 나는 omniauth 내 컨트롤러 코드를 추가?

답변

1
devise_scope :user do 
match "registrations/new_facebook" => "registrations#new_facebook" 
end 

내가 등록에서 복사 한 솔루션이를 컨트롤러의 new method와 new_facebook이라는 이름을 붙이면 모든 것이 예상대로 작동합니다!

0

나는 그 경로로 리디렉션하는 devise 메서드를 재정의하지 않는다고 생각합니다. 또한 devise 문서에 따르면 경로는 "devise_for"호출로 설정되어야합니다.

페이스 북 가입이 아닌 사례를 처리하기 위해 약간의 맞춤 로직이 필요할 수도 있지만 위키 페이지에서는 원하는 작업을 수행하는 방법을 설명합니다.

https://github.com/plataformatec/devise/wiki/How-To:-Redirect-to-a-specific-page-on-successful-sign-up-(registration)

해당 페이지의 일부 예제 코드 :

class RegistrationsController < Devise::RegistrationsController 
    protected 

    def after_sign_up_path_for(resource) 
    '/an/example/path' 
    end 
end 

및 경로에 대한 하나

devise_for :users, :controllers => { :registrations => "registrations" } 
+0

OmniauthCallbacksController에서 new_user_registration_url이 아닌 다른 방법으로 어떻게 리디렉션 할 수 있습니까? new_facebook_registration_url을 말하십니까? 컨트롤러에서 한 경우에 리다이렉션을 사용하고 싶습니다. –

관련 문제