OSDN Git Service

検索文字列が多くなったら100文字で切るように設定
authorTaro Matsuzawa aka. btm <btm@tech.email.ne.jp>
Tue, 16 Aug 2011 08:17:54 +0000 (17:17 +0900)
committerTaro Matsuzawa aka. btm <btm@tech.email.ne.jp>
Tue, 16 Aug 2011 08:17:54 +0000 (17:17 +0900)
app/controllers/products_controller.rb

index 8504e27..9ea7504 100644 (file)
@@ -2,6 +2,7 @@ class ProductsController < BaseController
   before_filter :load_product, :only => %w(show stock_table)
   before_filter :load_recommend_products, :only => %w(show)
   before_filter :load_recommend_ranking_products, :only => %w(show index)
+  before_filter :check_search, :only => %w(index search)
   
   def show
     load_seo_products_detail
@@ -112,4 +113,11 @@ class ProductsController < BaseController
     @recommend_xmls = Recommend.ranking_get(4)    
   end
 
+  def check_search
+    if params[:search] && params[:search].length > 100
+      params[:search] = params[:search][0, 100]
+      redirect_to :action => params[:action], :params => params
+    end
+  end
+
 end