Fix uniqueness of impressionable_type #71

merged 1 commit into from Apr 2, 2013

2 participants


Changed generating impressionable_type by from controller_name to controller_path for namespaced controllers.

For Foo::Bar controller, when we impressionist(@foo_bar, nil, unique: [:impressionable_type, :impressionable_id, :user_id] then actual SQL statement is

SELECT 1 AS one FROM "impressions" WHERE "impressions"."impressionable_id" = 1 AND "impressions"."impressionable_type" = 'Foo::Bar' AND (("impressions"."impressionable_type" = 'Bar' AND "impressions"."impressionable_id" = 1 AND "impressions"."user_id" = 1)) LIMIT 1

So impressions_count is always increasing, but it is not we supposed to.

@johnmcaliley johnmcaliley merged commit 26835a2 into charlotte-ruby:master Apr 2, 2013

1 check failed

Details default The Travis build could not complete due to an error
@yous yous deleted the yous:fix_unique_impressionable_type branch Dec 24, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment