0
我想在rails中引用当前用户的值。当前用户通过authlogic登录,但错误不存在。难道我做错了什么?我只想保持安全并告诉他们为什么他们不能输入地址。Rails authlogic/user无法检查错误。
<%= 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>
我不认为它使那么远。 '错误'的方法没有定义,所以我不能与它交互我可以返回?感谢您的答复! – Lethjakman
你解决了你的问题?你可以使用'try()'方法 – achempion