我有一个模型验证的是,当被触发时,提出该模型和字段名的消息之前,例如滑轨(3.1)的应用程序:Rails中更改错误消息模型
资料图像轮廓图像内容类型只有JPEG,GIF和PNG格式的文件允许个人资料图片
是否有避免的一种方式,所以它读取:
model.rb验证:只有JPEG,GIF和PNG格式的文件允许个人资料图片
validates_attachment_content_type :profile_image,
:content_type => ['image/jpeg', 'image/png', 'image/gif'],
:message => "Only jpeg, gif and png files are allowed for profile pictures"
出现错误,因为这代码我的布局的一部分:
<% if object.errors.any? %>
<div class="alert alert-message error" data-alert="alert">
<a class="close" data-dismiss="alert">×</a>
<ul>
<% object.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
请向我们展示显示此错误的视图的代码。 –
我加了。谢谢 – yellowreign