redirect - Rails 4, Devise - after_sign_in -


i trying make app in rails 4.

i trying follow along tutorial: http://sourcey.com/rails-4-omniauth-using-devise-with-twitter-facebook-and-linkedin/

i have moved after_sign_in_path omniauth callbacks controller application controller, can extend it.

my current attempt in application controller is:

def after_sign_in_path_for(resource)       if !resource.email_verified?            finish_signup_path(resource)         elsif params[:redirect_to].present?           store_location_for(resource, params[:redirect_to])         elsif  request.referer == new_session_url           profile_path(resource.profile) # or whatever route destination want         else           store_location_for(resource) || request.referer || root_path        end      end 

when try this, error:

argumenterror in users::omniauthcallbackscontroller#linkedin wrong number of arguments (0 1+) 

it highlights line of above method:

elsif  request.referer == new_session_url 

i don't know error message means.

my callbacks controller has:

def self.provides_callback_for(provider)     class_eval %q{       def #{provider}         @user = user.find_for_oauth(env["omniauth.auth"], current_user)           if @user.persisted?           sign_in_and_redirect @user,  event: :authentication            set_flash_message(:notice, :success, kind: "#{provider}".capitalize) if is_navigational_format?         else           session["devise.#{provider}_data"] = env["omniauth.auth"]           redirect_to new_user_registration_url         end       end     }   end 

is moving method out of omniauth_callbacks controller application controller?

can see i've done wrong?

my session routes are:

new_user_session       /users/sign_in(.:format)                          devise/sessions#new             user_session post      /users/sign_in(.:format)                          devise/sessions#create     destroy_user_session delete    /users/sign_out(.:format)                         devise/sessions#destroy 

taking tom's suggestion below, change redirect method in application controller to:

  def after_sign_in_path_for(resource)       if !resource.email_verified?            finish_signup_path(resource)         elsif params[:redirect_to].present?           store_location_for(resource, params[:redirect_to])         elsif  request.referer == new_session_path(:user)           profile_path(resource.profile) # or whatever route destination want         else           stored_location_for(resource) || request.referer || root_path        end      end 

the problem when try sign in, expect go user's profile show page. instead, go root path. adding (:user) end of 2nd elsif statement seems have caused happen. that's not want.

can see how set paths work in context?

devise provides new_session_path/url , takes resource name parameter

elsif request.referer == new_session_url(:user) 

for instance


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -