ruby on rails - Omniauth-facebook with Devise: "Missing passthru" errors -
i have devise authentication installed no problems. i'm trying add option log in facebook, using omniauth-facebook.
i followed instructions in this guide, i'm getting errors missing "passthru" documentation, when visiting url localhost:3000/auth/facebook
.
here's first error got:
unknown action action 'passthru' not found registrationscontroller
i tried bandaid fix adding empty "passthru" action controller:
def passthru end
and resolved error, got different 1 in return:
template missing missing template registrations/passthru, devise/registrations/passthru, devise/passthru, application/passthru {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :coffee]}. searched in: * "/home/user/project/app/views" * "/home/user/.rvm/gems/ruby-2.0.0-p648@railstutorial_rails_4_0/gems/devise-3.5.2/app/views"
i tried creating "passthru.html.erb" in stated folders, error remained. in case, think these errors emblematic of deeper problem.
has else run problem? find on this question, none of answers helpful.
my code far:
gemfile
gem 'devise' gem 'omniauth-facebook' gem 'omniauth'
routes.rb
devise_for :members, controllers: { registrations: 'registrations', omniauth_callbacks: 'registrations' }
member.rb
devise :database_authenticatable, :registerable, :omniauthable, :omniauth_providers => [:facebook] def self.from_omniauth(auth) where(provider: auth.provider, uid: auth.uid).first_or_create |member| member.email = auth.info.email member.password = devise.friendly_token[0,20] member.title = auth.info.name end end
registrations_controller.rb
def facebook @member = member.from_omniauth(request.env["omniauth.auth"]) if @member.persisted? sign_in_and_redirect @member, :event => :authentication set_flash_message(:notice, :success, :kind => "facebook") if is_navigational_format? else session["devise.facebook_data"] = request.env["omniauth.auth"] redirect_to new_member_registration_url end end def failure redirect_to root_path end def passthru end
initializers/devise.rb
config.omniauth :facebook, "<app_id>", "<app_secret>"
try :
update gemfile:
gem 'omniauth-facebook' gem 'omniauth'
goto rails_apps/yourapp/config/initializers/devise.rb
devise.setup |config| config.omniauth :facebook, "key", "secret" end
update user model
class user < activerecord::base devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :omniauthable, :omniauth_providers => [:facebook] def self.from_omniauth(auth) where(provider: auth.provider, uid: auth.uid).first_or_create |user| user.provider = auth.provider user.uid = auth.uid user.email = auth.info.email user.password = devise.friendly_token[0,20] end end end
goto : rails_apps/yourapp/config/routes.rb
rails.application.routes.draw devise_for :users resources :users end
edit in view
<%= link_to "sign in facebook", "/auth/facebook", id: "sign_in" %>
Comments
Post a Comment