Skip to content

Errors in controller class definitions are not surfaced #38060

@frantic

Description

@frantic

Steps to reproduce

Create a new Rails controller

class IndexController < ApplicationController
  call_to_a_function_that_does_not_exist

  def index
    puts "we are here"
  end
end

and register a route for it

# routes.rb
get "/", to: 'index#index'

Expected behavior

I'd expect to see and error like this in logs or webpage

NameError: undefined local variable or method `call_to_a_function_that_does_not_exist' for IndexController:Class

Actual behavior

If views/index/index.erb.html exists, Rails displays that view (but clearly isn't executing our index method, "we are here" is not in logs). Otherwise it shows an error that says "The action 'index' could not be found for IndexController".

System configuration

Rails version: 6.0.2.1

Ruby version: 2.6.5p114 (2019-10-01 revision 67812) [x86_64-linux]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions