My controller action is located in *controller/books_controller.rb*
def search_book
@found_book = Book.find_by_token(params[:token_no])
# After the book is found, I render the search_book.js.erb file using UJS
respond_to do |format|
format.js
end
The javascript file to modify the HTML content can be found here: views/books/search_book.js.erb
$("#found_book").html("<%= escape_javascript( render(:partial => "book_view") ) %>");
If the book is successfully found, a partial is rendered using UJS (Completed)
In case the book is not found i.e. if @found_book.nil? is true, I want to render a different partial for my div "found_book". How can this be achieved?