-
-
Notifications
You must be signed in to change notification settings - Fork 638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
accessible_by bug after upgrading to rails 5.2 #478
Comments
I'm seeing what seems to be the same error, using postgresql |
The error is based on the pieces of code that turn ActiveRecord queries into SQL, so the issue will exist on any SQL based DB. @kylekeesling |
Ok good to know. I just wanted to make sure I provided the right context for what I was seeing. |
@lizzyaustad Thanks very much for your for your PR. It allowed us to move forward using Rails 5.2.0-rc1 in the meantime. |
I'm seeing deprecation warnings apparently triggered by accessible_by: |
This issue should be solved with the latest version of CanCanCan |
Was this resolve and from what version, I currently have it on 1.17.0 |
@capjuancode you probably already figured this out, but for one app we just upgraded on, we went from 1.15 to 2.3.0. Leaving this here for anyone else who might stumble across it. For reference, this issue arose when upgrading to Rails 5.2 |
Steps to reproduce
accessible_by
(or run active_record_adapter spec)Gist: https://gist.github.com/lizzyaustad/4096f904f6d0b409462f7fdf7c60b65e
Expected behavior
Should be able to use
accessible_by
without raising exceptionActual behavior
An exception is raised:
This is due to a change in Rails 5.2 that creates a BindParam node for the attribute. The BindParam node moves the intended value for the query under
.value_before_type_cast
instead of the previous.val
it had before with the Casted node, resulting in a query like the one above, where the?
value does not get filled in:("articles"."published" = ?)) LIMIT ?
Possible fixes
If this error persists with the official release of Rails 5.2, this change in active_record_4_adapter.rb could fix the issue on the cancancan side.
System configuration
Rails version: 5.2.0.beta2
Ruby version: 2.3.0
CanCanCan version 2.0.0
The text was updated successfully, but these errors were encountered: