Skip to content

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

Open
@Laykou

Description

@Laykou
  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>)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions