I need to append a single ActiveRecord object onto a loaded ActiveRecord::Relation.
E.g:
class BooksController < ApplicationController
def index
@books = Book.where(author: User.find(params[:user_id]))
@books << Book.find_by_name("One More Book")
end
end
As shown above, I have tried ActiveRecord's << method, but it returns the error:
NoMethodError: undefined method `<<' for #<Book::ActiveRecord_Relation:0x007f9fbdc6db80>
Is there an elegant way of doing this?
Thanks!