For some reason my query is now returning an array of hashes when I need an array of objects. I can't figure out what to do.
inbox_sql = self.mailbox.inbox.where('conversations.id IN (?)', active_conversations).reorder('').to_sql
sentbox_sql = self.mailbox.sentbox.reorder('').to_sql
sql = "#{inbox_sql} UNION #{sentbox_sql}"
conversations = Profile.connection.execute(sql)
When
self.inbox.mailbox.first.class
returns
Conversation(id: integer, subject: string, created_at: datetime, updated_at: datetime)
BUT
ActiveRecord::Base.connection.execute(sql).first.class
returns hash, which is problematic and ruining the rest of my code in the views. [ Used to return a Conversation object in a less optimal way], but I need it to return a Conversation(..) object
UNIONandto_sqlstuff ? It seems too complicated and may be rewritten with a simple where that would return Conversations. What are the relation betweenself,mailboxandinbox/sentbox?