我使用Omniauth作为我登录Rails应用程序的唯一方法.
问题是:当用户单击"注销"时,页面重新加载并且Logout链接仍然存在(尽管user_signed_in?逻辑包装它).这让我相信用户实际上并没有退出
这是我的index.html.erb:
<% if user_signed_in? %>
<%= link_to "Authenticate with Google", user_omniauth_authorize_path(:google_oauth2) %>
<% else %>
<%= link_to('Logout', destroy_user_session_path, :method => :delete) %>
<% end %>
Run Code Online (Sandbox Code Playgroud)
还有我的user.rb
def self.from_omniauth(auth)
if user = User.find_by_email(auth.info.email)
user.provider = auth.provider
user.uid = auth.uid
user
else
where(provider: auth.provider, uid: auth.uid).first_or_create do |user|
user.provider = auth.provider
user.uid = auth.uid
user.email = auth.info.email # THIS (user.email) value i want to provide to my registration form as default value
end
end
end
Run Code Online (Sandbox Code Playgroud)
我的omniauth_callbacks_controller.rb …
我正在尝试检查参数是否等于视图中的 if 语句的值:
<% if param[:knowsifemployermatches] == "Yes" %>show<% end %>
Run Code Online (Sandbox Code Playgroud)
但我收到这个错误:
undefined local variable or method `param' for #<#<Class:0x000001070d2688>:0x00000103a8cf88>
Run Code Online (Sandbox Code Playgroud)