Last active
December 20, 2015 20:59
-
-
Save jgrannas/6194740 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def self.filter_with_params(params) | |
scoped = self.where("styles.name != ''") | |
scoped = scoped.includes(:tags)#, :collection) | |
#params[:t].inject(scoped){|memo, val| memo.where(:tags => {:name => val})} if params[:t] | |
if params[:t] | |
params[:t].each do |t| | |
scoped = scoped.where(:tags => {:name => t}) | |
end | |
end | |
scoped | |
end | |
Started GET "/styles?utf8=%E2%9C%93&t%5B%5D=engagement&t%5B%5D=Halo" for 127.0.0.1 at 2013-08-09 11:58:46 -0400 | |
Processing by StylesController#index as JSON | |
Parameters: {"utf8"=>"✓", "t"=>["engagement", "Halo"]} | |
[1m[35mUser Load (0.3ms)[0m SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1 | |
[1m[36m (0.4ms)[0m [1mSELECT COUNT(*) FROM "roles" INNER JOIN "users_roles" ON "roles"."id" = "users_roles"."role_id" WHERE "users_roles"."user_id" = 1 AND (((roles.name = 'admin') AND (roles.resource_type IS NULL) AND (roles.resource_id IS NULL)))[0m | |
[1m[35mCollection Load (0.3ms)[0m SELECT "collections".* FROM "collections" | |
[1m[36mSQL (0.4ms)[0m [1mSELECT "styles"."id" AS t0_r0, "styles"."collection_id" AS t0_r1, "styles"."item_number" AS t0_r2, "styles"."name" AS t0_r3, "styles"."title" AS t0_r4, "styles"."description" AS t0_r5, "styles"."slug" AS t0_r6, "styles"."content" AS t0_r7, "styles"."created_at" AS t0_r8, "styles"."updated_at" AS t0_r9, "styles"."price" AS t0_r10, "styles"."data" AS t0_r11, "styles"."meta_title" AS t0_r12, "styles"."meta_desc" AS t0_r13, "styles"."active" AS t0_r14, "tags"."id" AS t1_r0, "tags"."name" AS t1_r1, "tags"."created_at" AS t1_r2, "tags"."updated_at" AS t1_r3, "tags"."tag_category_id" AS t1_r4 FROM "styles" LEFT OUTER JOIN "tagizations" ON "tagizations"."style_id" = "styles"."id" LEFT OUTER JOIN "tags" ON "tags"."id" = "tagizations"."tag_id" WHERE "tags"."name" = 'engagement' AND "tags"."name" = 'Halo' AND (styles.name != '')[0m | |
Completed 200 OK in 22ms (Views: 0.1ms | ActiveRecord: 1.4ms) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment