Open rvelasquez opened 11 years ago
Also this problem only started happening when I tried to upgrade from Rails 3.2.2 to 3.2.12.
Spent some time tracking this down. Looks like it's a bug in the current release of Rails 3.2.2. More info here: https://github.com/rails/rails/issues/9511
I had this problem as well. I tracked it down and submitted this pull request. https://github.com/rails/rails/pull/9859
This issue seems to be fixed in master. ActiveRecordAdapter#tableized_conditions will now return something that ActiveRecord::PredicateBuilder can deal with. I guess, until the next version of the gem is released, it's still going to be an issue for users.
Thanks for your submission! The ryanb/cancan repository has been inactive since Sep 06, 2013. Since only Ryan himself has commit permissions, the CanCan project is on a standstill.
CanCan has many open issues, including missing support for Rails 4. To keep CanCan alive, an active fork exists at cancancommunity/cancancan. The new gem is cancancan. More info is available at #994.
If your pull request or issue is still applicable, it would be really appreciated if you resubmit it to CanCanCan.
We hope to see you on the other side!
Hi,
I have an ability defined like so:
can :manage, AssignedTask, :task => {:job => {:franchise_id => user.franchise_id}}
My models define that the AssignedTask belongs to a Task which belongs to a Job which belongs to a Franchise.
When I use AssignedTask.accessible_by(ability) I get the error:
ActiveRecord::StatementInvalid: PG::Error: ERROR: column tasks.jobs does not exist LINE 1: ...IN "jobs" ON "jobs"."id" = "tasks"."job_id" WHERE "tasks"."j... ^ : SELECT "assigned_tasks".* FROM "assigned_tasks" INNER JOIN "tasks" ON "tasks"."id" = "assigned_tasks"."task_id" INNER JOIN "jobs" ON "jobs"."id" = "tasks"."job_id" WHERE "tasks"."jobs" = '--- :franchise_id: 1 '
The issue is the final WHERE clause which shouldn't be there and I have no idea where it's coming from. AssignedTask.accessible_by(ability).to_sql returns:
"SELECT \"assigned_tasks\".* FROM \"assigned_tasks\" INNER JOIN \"tasks\" ON \"tasks\".\"id\" = \"assigned_tasks\".\"task_id\" INNER JOIN \"jobs\" ON \"jobs\".\"id\" = \"tasks\".\"job_id\" WHERE \"tasks\".\"jobs\" = '---\n:franchise_id: 1\n'"
Any ideas?