Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails render status: :not found missing template error

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!

like image 968
ds998 Avatar asked Dec 05 '22 13:12

ds998


1 Answers

: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

like image 91
Philidor Avatar answered Dec 22 '22 00:12

Philidor