新建贴吧描述为空不能新建、搜索空内容添加提示

This commit is contained in:
z9hang 2014-07-05 14:43:15 +08:00
parent 5c93442c79
commit f5b69be967
7 changed files with 15 additions and 11 deletions

View File

@ -26,7 +26,7 @@ class ContestsController < ApplicationController
# @contests = Contest.visible
# @contests ||= []
@offset, @limit = api_offset_and_limit({:limit => 10})
@contests = Contest.visible
@contests = Contest.visible
@contests = @contests.like(params[:name]) if params[:name].present?
@contest_count = @contests.count
@contest_pages = Paginator.new @contest_count, @limit, params['page']

View File

@ -99,7 +99,8 @@ class CoursesController < ApplicationController
# add by nwb
def search
courses_all = Course.all_course
name = params[:name]
(redirect_to courses_path, :notice => l(:label_sumbit_empty);return) if name.blank?
@courses = courses_all.visible
if params[:name].present?
@courses_all = @courses.like(params[:name])

View File

@ -166,6 +166,8 @@ class ForumsController < ApplicationController
def search_forum
# @forums = paginateHelper Forum.where("name LIKE '%#{params[:name]}%'")
name = params[:name]
(redirect_to forums_path, :notice => l(:label_sumbit_empty);return) if name.blank?
@offset, @limit = api_offset_and_limit({:limit => 10})
@forums_all = Forum.where("name LIKE '%#{params[:name]}%'")
@forums_count = @forums_all.count

View File

@ -373,7 +373,7 @@ class UsersController < ApplicationController
def search
sort_init 'login', 'asc'
sort_update %w(login firstname lastname mail admin created_on last_login_on)
(redirect_to users_path, :notice => l(:label_sumbit_empty);return) if params[:name].blank?
case params[:format]
when 'xml', 'json'
@offset, @limit = api_offset_and_limit({:limit => 15})

View File

@ -88,7 +88,8 @@ class WelcomeController < ApplicationController
when :users_student
redirect_to users_search_path(:name => search_condition, :role => :student)
else
redirect_to home_path, :alert => l(:label_sumbit_empty)
#redirect_to home_path, :alert => l(:label_sumbit_empty)
(redirect_to home_path, :notice => l(:label_sumbit_empty);return) #if params[:name].blank?
end
}
end

View File

@ -9,7 +9,7 @@ class Forum < ActiveRecord::Base
'memo_count',
'last_memo_id',
'creator_id'
validates_presence_of :name, :creator_id
validates_presence_of :name, :creator_id, :description
validates_length_of :name, maximum: 50
validates_length_of :description, maximum: 255
validates :name, :uniqueness => true

View File

@ -3,17 +3,17 @@
<h3><%=l(:label_memo_new)%></h3>
<% if User.current.logged? %>
<%= labelled_form_for(@memo, :url => create_memo_forum_path(@forum), :html => {:multipart => true} ) do |f| %>
<% if @memo.errors.any? %>
<!--<#% if @memo.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@memo.errors.count, "error") %> prohibited this memo from being saved:</h2>
<h2><#%= pluralize(@memo.errors.count, "error") %> prohibited this memo from being saved:</h2>
<ul>
<% @memo.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
<#% @memo.errors.full_messages.each do |msg| %>
<li><#%= msg %></li>
<#% end %>
</ul>
</div>
<% end %>
<#% end %> -->
<div class="actions" style="max-width:680px">
<p><%= f.text_field :subject, :required => true%></p>
<p style="max-width:680px"><%= f.text_area :content, :required => true, :id => 'editor02' %></p>