"the “:nothing” option is deprecated and will be removed in rails 5.1" Code Answer

2

according to the rails source, this is done under the hood when passing nothing: true in rails 5.

if options.delete(:nothing)
  activesupport::deprecation.warn("`:nothing` option is deprecated and will be removed in rails 5.1. use `head` method to respond with empty response body.")
  options[:body] = nil
end

just replacing nothing: true with body: nil should therefore solve the problem.

class pagescontroller < applicationcontroller
  def action
    render body: nil
  end
end

alternatively you can use head :ok

class pagescontroller < applicationcontroller
  def action
    head :ok
  end
end
By KyleM on June 3 2022

Answers related to “the “:nothing” option is deprecated and will be removed in rails 5.1”

Only authorized users can answer the Search term. Please sign in first, or register a free account.