Skip to content
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

.to_sql does not work with joined paranoia model: Undefined method 'relation' for Arel::Nodes::BindParam #496

Open
Laykou opened this issue Jul 4, 2020 · 0 comments
Labels

Comments

@Laykou
Copy link

Laykou commented Jul 4, 2020

  1. .to_sql method works without acts_as_paranoid
  2. Calling the .to_sql on the User model without joins works as well:
> User.all.to_s
=> "SELECT \"users\".* FROM \"users\" WHERE \"users\".\"deleted_at\" IS NULL" 
  1. But calling .to_sql with joins on the paranoia model throws:
NoMethodError (undefined method 'relation' for #<Arel::Nodes::BindParam:0x00007f91ece6e120>)

How to reproduce:

class User < ApplicationRecord
  acts_as_paranoid
end

class UserSetting < ApplicationRecord
  belongs_to :user
end

UserSetting.joins(:user).to_sql

# NoMethodError (undefined method 'relation' for #<Arel::Nodes::BindParam:0x00007f91ece6e120>)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants