app/controllers/application_controller.rb
def redirect_to_back(options)
    default = options.delete(:default) || root_url
    if request.env["HTTP_REFERER"].present? and request.env["HTTP_REFERER"] != request.env["REQUEST_URI"]
      redirect_to :back, options
    else
      redirect_to default, options
    end
  end
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
Prevent CSRF attacks by raising an exception.
For APIs, you may want to use :null_session instead.
Prevent CSRF attacks by raising an exception . For APIs you may want to use : null_session instead .
def redirect_to_back(options)
    default = options.delete(:default) || root_url
    if request.env["HTTP_REFERER"].present? and request.env["HTTP_REFERER"] != request.env["REQUEST_URI"]
      redirect_to :back, options
    else
      redirect_to default, options
    end
  end
def redirect_to_back ( options ) default = options . delete ( :default ) || root_url if request . env [ "HTTP_REFERER" ] . present? and request . env [ "HTTP_REFERER" ] != request . env [ "REQUEST_URI" ] redirect_to :back , options else redirect_to default , options end end
Prevent CSRF attacks by raising an exception.
Prevent CSRF attacks by raising an exception .
options