estoy tratando de hacer una conexion con facebook y ruby on rails utilizando el omniauth-facebook, pero cuando trato de hacer una conexion me manda un error de "no implicit conversion of Symbol into Integer", seria de mucha ayuda si me pueden a clarar donde estoy cometiendo el error este es el codigo que estoy utilizando:
en la carpeta initializers creo un archivo omniauth.rb:
Rails.application.config.middleware.use OmniAuth::Builder do
provider :facebook, 'xxxxface_book_idxxxxx', 'xxxsecret_id_facebookxxxxxx'
end
creo una ruta en routes.rb:
get 'auth/:provider/callback', to: 'sessions#create'
get 'auth/failure', to: redirect('/')
get 'signout', to: 'sessions#destroy', as: 'signout'
seguido de un controller sessions_controller.rb:
def create
user = User.from_omniauth("omniauth.auth")
session[:user_id] = user.id
redirect_to root_url
end
def destroy
session[:user_id] = nil
redirect_to root_url
end
luego creo un modelo llamado user.rb:
def self.from_omniauth(auth)
where(auth.slice(:provider,:uid)).first_or_initialize.tap do |user|
user.provider = auth.provider
user.uid = auth.uid
user.name = auth.info.name
user.oauth_token = auth.credentials.token
user.oauth_expires_at = Time.at(auth.credentials.expires_at)
user.save!
end
end
Luego en application_controller.rb :
private
def current_user
@current_user ||= User.find(session[:user_id]) if session[:user_id]
end
helper_method :current_user
Luego agrego en application.html.erb:
<% if current_user%>
Signed in as <strong><%= current_user.name %></strong>
<%= link_to "Sign out", signout_path, id: "sign_out"%>
<% else %>
<%= link_to "Sign in with Facebook", "/auth/facebook", id: "sign_in"%>
<% end %>
pero cuando hago click en el link me manda el error :
alguna idea en donde puedo estar cometiendo el error??? realmente apreciare si me pueden ayudar con esto.