Rails 4 - Redirect path -
i'm trying make app in rails 4.
i'm trying follow tutorial setup devise omniauth.
i have user model , profile model. associations are:
user.rb
has_one :profile
profile.rb
belongs_to :user
in omniauth callbacks controller, have:
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
in omniauth callbacks controller, currently, when user authenticates, redirect goes root path (i'm not sure why). think has current redirect @user, not having show page (which doesnt - there no views in user views folder).
i want go user's profile show page.
i can't figure out how write path. have tried each of:
if @user.persisted? sign_in_and_redirect @user.profile, event: :authentication if @user.persisted? sign_in_and_redirect @user.profile(profile.id), event: :authentication if @user.persisted? sign_in_and_redirect @user.profile_id, event: :authentication
does know how make redirect path. there user , user have profile. i"m stuck on how express path profile's show page.
in applicationcontroller add
def after_sign_in_path_for(resource) profile_path(resource.profile) # or whatever route destination want end
Comments
Post a Comment