0
アプリケーションにログインするためにdevise omniauthを使用しているレールアプリ。 成功ログイン後、私は、@ current_user.emailログイン後にユーザ名と部分的にレンダリング
$(function() {
$('#facebook-connect').click(function(e) {
e.preventDefault();
FB.login(function(response) {
if(response.authResponse) {
$.ajax({
type: 'POST',
url: '/users/auth/facebook/callback',
dataType: 'json',
data: {signed_request: response.authResponse.signedRequest},
success: function(data, textStatus, jqXHR) {
$('#loginout_button').html("<%= j render(:partial => 'account_info') %>");
},
}
}
, {scope: 'email'});
});
});
と部分をdisplayes htmlコードのある場所に、 "ログイン" ボタンを再度したいと思います:
<% if user_signed_in? %>
<p class="text-left small"><%=current_user.email%></p>
<p class="text-left">
<%= link_to destroy_user_session_path, :method => :delete do %>
<%=t('auth.logout')%>
<% end%>
しかし、もちろん、部分的にページが読み込まれ、それがログアウトしたユーザーのテンプレートを生成するため、うまくいきません。
$('#loginout_button').html(" <li>\n <button type=\"button\" onclick=\"openLoginModal(); return false;\">Login<\/button>\n <\/li>\n");
devise @current_user状態に基づいてテンプレートを生成する必要があります。
あなたのアドバイスを受けました! – user664859