apply tags and cates for fronted. from now app developer can use param category_id and tag_id freely.

This commit is contained in:
Matt K. Fu 2013-05-31 17:37:45 +08:00
parent 7729161123
commit dd206437d8
2 changed files with 2 additions and 5 deletions

View File

@ -1,10 +1,8 @@
class OrbitWidgetController< OrbitFrontendComponentController class OrbitWidgetController< OrbitFrontendComponentController
include FrontEndArrayParamsHelper include FrontEndArrayParamsHelper
before_filter {get_tags_and_cates(params)}
before_filter :get_tags_and_cates def get_tags_and_cates(params)
def get_tags_and_cates
binding.pry
params = tags_and_cates(params) params = tags_and_cates(params)
end end

View File

@ -6,7 +6,6 @@ module FrontEndArrayParamsHelper
#That's why we need tags_and_cates #That's why we need tags_and_cates
def tags_and_cates(params) def tags_and_cates(params)
params["category_id"] = params["category_id"].collect{|t| t.gsub(/\"|\[|\]/,'').split(",").each(&:strip!)}.flatten if params["category_id"].is_a? Array params["category_id"] = params["category_id"].collect{|t| t.gsub(/\"|\[|\]/,'').split(",").each(&:strip!)}.flatten if params["category_id"].is_a? Array
params["tag_id"] = params["tag_id"].collect{|t| t.gsub(/\"|\[|\]/,'').split(",").each(&:strip!)}.flatten if params["tag_id"].is_a? Array params["tag_id"] = params["tag_id"].collect{|t| t.gsub(/\"|\[|\]/,'').split(",").each(&:strip!)}.flatten if params["tag_id"].is_a? Array