0
我有兩個表,一個Users表和一個名爲School_Users的表。 School_Users表處理包括電子郵件在內的用戶的角色和各種其他字段。RoR:使用Devise委託電子郵件並登錄
我已經委託電子郵件給此模型:
user.rb
delegate :email, to: :school_user
,它似乎工作,我使用積極管理和測試它。
但是,當我去簽在申請我得到這個錯誤:
User#email delegated to school_user.email, but school_user is nil: #<User id: nil, email: "", encrypted_password: "", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 0, current_sign_in_at: nil, last_sign_in_at: nil, current_sign_in_ip: nil, last_sign_in_ip: nil, confirmation_token: nil, confirmed_at: nil, confirmation_sent_at: nil, unconfirmed_email: nil, failed_attempts: 0, unlock_token: nil, locked_at: nil, created_at: nil, updated_at: nil, admin: false, first_name: nil, last_name: nil>
我想這只是一個觀點,這是我的形式電子郵件字段:
/會話/新.html.erb
<%= simple_form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
<p class="loginLogo"><%= image_tag "logo.png", class: "text-center" %></p>
<%= f.label :email, :class => "text-center font16" %>
<span class="glyphicon glyphicon-envelope"></span>
<%= f.email_field :email, :class => "insdat", :placeholder => "Email Address", autofocus: true %>
<%= f.label :password, :class => "text-center font16" %>
<span class="glyphicon glyphicon-lock"></span><%= f.password_field :password, :class => "insdat" , :placeholder => "Password", autocomplete: "off" %>
<div class="actions">
<%= f.submit "Log in", :class => "expanded button logbtn" %>
</div>
<div class="text-center">
<% end %>
我該如何獲取要載入的表單?我認爲我必須定義領域朝着school_user或找到路徑?
謝謝。如果需要,歡迎發佈更多代碼。
您好,感謝,只是想知道這是否有在您看來,什麼缺點?謝謝。我正在使用Devise。 – Co2