I pull a record as:
def self.imp_broadcast_preview!
Broadcast.where(for_gamers: true).order(:created_at).last
end
And then in my controller I have:
def index
@conversations = Conversation.where(gamer: @gamer)
@conversations << Broadcast.imp_broadcast_preview!
end
The above code works properly in Rails 4.2
and merges the last broadcast message in the conversations. I just updated my codebase to Rails 5.2
and now I am getting an error:
NoMethodError (undefined method `<<' for #<Conversation::ActiveRecord_Relation:0x00007fd2541baca0>)
I tried using merge
instead but that throws an error as well since broadcast
is not an activerecord relation