ActionController::RoutingError (uninitialized constant ApplicationController):

1.8k views Asked by At

I am attempting to upgrade my rails application. I've never done this before but decided it best after learning about one of the recent features that are in 5.1 (I was using 5.0.7). I think my ultimate goal is to go all the way to the latest, since I realize that long term it is a good idea.

One thing that I am stuck on after making the changes, is that I am running into routing a routing error.

The server error I get is

ActionController::RoutingError (uninitialized constant Downtown::ApplicationController):

When I deployed this to heroku (thought it was all set before I did so) the errors i get are

! Unable to load application: NameError: uninitialized constant Downtown::ApplicationController
bundler: failed to load command: puma (/app/vendor/bundle/ruby/2.5.0/bin/puma)
NameError: uninitialized constant Downtown::ApplicationController
/app/app/controllers/properties_controller.rb:1:in `<top (required)>'

One thing in my routes that I had before this switch was I have some nested routing. Yet looking at the release notes I haven't found anything that would require changes within my routes files, and the only thing in the release notes that are related are Direct & resolved routing which I don't think i'm using.

My routes are

  resources :downtowns do
    resources :properties do
    end
  end

My application controller is basically empty.

class ApplicationController < ActionController::Base
  protect_from_forgery with: :exception
end

My downtown controller is

class DowntownsController < ApplicationController
  before_action :find_downtown, only: [:show, :edit, :update, :destroy]
  before_action :authenticate_user!, except: [:index, :show]

  ....the general def show and create files and such....

end

My properties controller is

class PropertiesController < Downtown::ApplicationController
  before_action :find_property, only: [:show, :edit, :update, :destroy]
  before_action :authenticate_user!, except: [:index, :show]

  ....the general def show and create files and such....

end

Both of my models route to the ApplicationRecord

class Downtown < ApplicationRecord
end

class Property < ApplicationRecord
end

My application record is below. I have it set to ActiveRecord::Base which i believe to be correct?

class ApplicationRecord < ActiveRecord::Base
  self.abstract_class = true
end

My app/config/environment.rb file fails on the initialize! line.

# Load the Rails application.
require_relative 'application'

# Initialize the Rails application.
Rails.application.initialize!

I'm at the point where I am shooting in the dark here. Would anyone have any idea what I am missing at the point?

0

There are 0 answers