我在登录后将用户重定向到自己的页面时遇到问题。
我正在使用RAILS 4和Ajax来处理它。
我的登录表单:
<%= form_for(resource,:html => {"data-parsley-validate" => true},:'data-parsley-validate' => true,:class=>"new_user",:id=>"new_user",:remote=> true,format: :json,as: resource_name, url: session_path(resource_name)) do |f| %>
<div class="form-group">
<%= f.email_field :email,:class=>"user-input form-control" ,:id=>"user-name" ,:placeholder=>t('username'), autofocus: true ,required: true%>
</div>
<div class="form-group">
<%= f.password_field :password,:class=>"user-input form-control", :id=>"password", :placeholder=>t('password'), autocomplete: "off",required: true %>
</div>
<span class="validation-message" style="color: white;"><%= t('incorect_password') %></span>
<div class="remember-me">
<div class="squared">
<%= f.check_box :remember_me, :id=>"remember-me"%>
<label style="left: 0px;" for="remember-me"><span><%= t('remember_me') %> <!--Atcerēties mani --></span></label>
</div>
</div>
<%= button_tag t('login') ,:class=>"blue-button btn btn-default" %>
<%= link_to '#',:id=>"forgot-password-modal", :class => "pull-right forgot-pass" do %>
<span><%= t('forgot_password') %></span>
<% end %>
<%end%>
应用程序控制器:
def after_sign_in_path_for(resource)
if current_user.present? and current_user.role?(:advertisement)
current_user.girl
end
end
问题:
Ajax似乎有效,但登录成功的实际可视化仅在我重新加载页面时才有效。然后显示提供密码的chrome消息。
你能给我任何建议吗?
谢谢。