I want firstly add attributes with select and then order by them.
label = Arel.sql(
%q(
case label
when 'x' then 1
when 'y' then 2
end
)
)
Item.all.select("*, 'x' as label").order(label)
Error:
ActiveRecord::StatementInvalid (PG::UndefinedColumn: ERROR: column "label" does not exist)
LINE 2: case label