I currently have:
book = Book.find(book_id)
json = render :json => book.to_json(:only => [ :book_id, :description,
:isbn, :author, :title ])
However, I want to be able to add a field called book_id to book. I’m
pretty new to rails, and have no idea how to do this.
I’ve tried:
book = Book.find(book_id)
book.merge({ :book_id => params[:book] })
json = render :json => book.to_json(:only => [ :book_id, :description,
:isbn, :author, :title ])
But I get an error message saying that merge isn’t a method of book.
Any ideas?
Note: In case it isn’t obvious, book is the results of a database query
that finds a book_id.