ActiveRecord: Transform scope to arel node, with strings

Viewed 678

I have this scope:

scope :finished, -> { where(status: "finished") }

I found that that transform a scope into an arel node is just calling #arel on it. All this because I have a complex query, and I want to reuse the conditions:

table.join(.....).where(table[:id].eq(2)).where(ThatClass.finished.arel).to_sql
#=> .... AND "that_classes"."status" = $1 ......

Why is 'finished' not there? How can I integrate it? This only happens with strings, as if it were an integer or a not null scope, it would print exactly as expected

0 Answers
Related