diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index adadfbf44..1b172e0cc 100644 --- a/app/controllers/contests_controller.rb +++ b/app/controllers/contests_controller.rb @@ -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'] diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index b46ab52b1..157de5ce7 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -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]) diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index b54d98b8f..f3ebfad88 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -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 diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 144e86f4f..1c2db7f79 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -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}) diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 9c72d301f..3e708b94a 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -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 diff --git a/app/models/forum.rb b/app/models/forum.rb index e6b16df39..cd9c210dd 100644 --- a/app/models/forum.rb +++ b/app/models/forum.rb @@ -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 diff --git a/app/views/forums/show.html.erb b/app/views/forums/show.html.erb index 72e7ce221..34fc953da 100644 --- a/app/views/forums/show.html.erb +++ b/app/views/forums/show.html.erb @@ -3,17 +3,17 @@
<%= f.text_field :subject, :required => true%>
<%= f.text_area :content, :required => true, :id => 'editor02' %>