开发者

Devise sign_up ignores remember_me value

I'm just getting started with Devise. I have a:

class User < ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :validatable

  # Setup accessible (or protected) attributes for your model
  attr_accessible :email, :password, :password_confirmation, :remember_me
end

and I've altered my sign_up view to:

<h2>Sign up</h2>

<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
  <%= devise_error_messages! %>

  <div><%= f.label :email %><%= f.email_field :email %></div>

  <div><%= f.label :password %><%= f.password_field :password %></div>

  <div><%= f.label :password_confirmation %><%= f.password_field :password_confirmation %></div>

  <div><%= f.label :contact_me %><%= f.check_box :contact_me %></div>

  <div><%= f.label :remember_me %><%= f.check_box :remember_me %></div>

  <div><%= f.submit "Sign up" %></div>
<% end %>

<%= render :partial => "devise/shared/links" %>

However, checking the POST response, I can see the remember_user_token set in Cookie: after sign-up whether I ticked "Remember me" or not. Anyone know why that is, and how to stop i开发者_开发技巧t?

By comparison, signing in only sets that cookie if the box is ticked, as expected.


I now that you are using for_for, but i use form_tag... Such code works on my project:

.form
  = form_tag new_user_session_path do  
    = email_field_tag 'user[email]', nil, :placeholder => "Ваш e-mail", :required => true
    = password_field_tag 'user[password]', nil, :placeholder => "Ваш пароль", :required => true
    .submit-area
        = submit_tag "Вход", :class => "orange-button"
        = check_box_tag 'user[remember_me]', true
        .login-link
          Запомнить меня

So that part will work fine:

= check_box_tag 'user[remember_me]', true
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜