While developing an app for a course,I hit upon a stumbling block:
The error screen
And here is my Stocks Controller error, where the error appears:
class StocksController < ApplicationController
def search
if params[:stock]
@stock = Stock.find_by_ticker(params[:stock])
@stock ||= Stock.new_from_lookup(params[:stock])
end
if @stock
render json: @stock
#render partial: 'lookup'
else
render status: :not_found ,nothing: true
end
end
end
On the course, they have the same code as I do,but for them, it works.The only difference I am aware of is that they are working on Rails 4(Nitrous),and that I am working on Rails 5(Mac OS X/Atom IDE/GitLab repository).Please help me if you can!Thank you in advance!
:nothing
option is deprecated and will be removed in Rails 5.1. Use head
method to respond with empty response body.
Try this:
render body: nil, status: :not_found
or:
head :not_found
Please don't post errors as images, copy-past the text
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With