新建贴吧错误提示修改

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.html { redirect_to @forum, notice: l(:label_forum_create_succ) }
format.json { render json: @forum, status: :created, location: @forum } format.json { render json: @forum, status: :created, location: @forum }
else else
flash.now[:error] = "#{l :label_forum_create_fail}: #{@forum.errors.full_messages[0]}"
format.html { render action: "new" } format.html { render action: "new" }
format.json { render json: @forum.errors, status: :unprocessable_entity } format.json { render json: @forum.errors, status: :unprocessable_entity }
end end

View File

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