我正在尝试在 rails 中引用当前用户的值。当前用户通过authlogic登录,但不存在错误。难道我做错了什么?我只是想安全并告诉他们为什么他们不能输入地址。
<%= form_for(current_user.address.build) do |f| %>
<% if current_user.address.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(current_user.address.errors.count, "error") %> prohibited this user from being saved:</h2>
<ul>
<% current_user.address.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
错误:
undefined method `errors' for #<ActionView::Helpers::FormBuilder:0x007f9584665e88>