Hi here is my ActiveRelation query that works fine on local development environment (SQLite)
@table2_items = @table1var.table2_items.find(:all, conditions: ["status1 is ? AND status2 is ? AND start_datetime > ?", true, nil, Time.now.to_datetime], order: [:field_id, :created_at])
I think it's just a syntax error... Can anyone help? Thanks
Your SQL ends up with this in it:
status1 is 't'
and that's invalid: is
is only used with is null
, is distinct from
, and similar constructs.
You should upgrade to a more modern syntax and leave most of the work to ActiveRecord:
@table2_items = @table1var.table2_items
.where(:status1 => true, :status2 => nil)
.where('start_datetime > ?', Time.now)
.order(:field_id, :created_at)
That leaves most of the "how do I compare things?" logic up ActiveRecord and is a bit easier to read as the placeholders and their values aren't separated from each other.
Once you have this problem sorted out, you really should install PostgreSQL in your development environment so that you're developing and deploying on the same stack. There are all sorts of differences between databases that no ORM can protect you from.