新建贴吧错误提示修改

This commit is contained in:
z9hang 2014-07-05 11:44:05 +08:00
parent 470f40db82
commit 01da0852e3
2 changed files with 7 additions and 6 deletions

View File

@ -129,6 +129,7 @@ class ForumsController < ApplicationController
format.html { redirect_to @forum, notice: l(:label_forum_create_succ) }
format.json { render json: @forum, status: :created, location: @forum }
else
flash.now[:error] = "#{l :label_forum_create_fail}: #{@forum.errors.full_messages[0]}"
format.html { render action: "new" }
format.json { render json: @forum.errors, status: :unprocessable_entity }
end

View File

@ -3,15 +3,15 @@
<div id="share_new" style = "width: 500px; margin:0 auto; " >
<%= labelled_form_for(@forum) do |f| %>
<% if @forum.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@forum.errors.count, "error") %> prohibited this forum from being saved:</h2>
<!--<div id="error_explanation">
<h2><#%= pluralize(@forum.errors.count, "error") %> prohibited this forum from being saved:</h2>
<ul>
<% @forum.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
<#% @forum.errors.full_messages.each do |msg| %>
<li><#%= msg %></li>
<#% end %>
</ul>
</div>
</div> -->
<% end %>
<div class="actions" style="margin:10px">
<div class="field">