Shotgun Loader Boot Error


#1

I am completely new to Lotus, and I’m following this example to create a simple Lotus app. When I start it up and view it in my browser, I receive the following:

Boot Error

Something went wrong while loading /Users/morgan/Dev/lotus/onefileapp/config.ru

NameError: uninitialized constant Shotgun::Loader::OneFile::Controller

I don’t really understand what’s wrong. The code is in the same form shown in the lotus/application.rb:L112 as of right now.

Help is appreciated!


#2

@mlaco Hello and welcome. I’m sorry if I’ve missed this discussion. My apologize.

That linked blog post is outdated. It was written before Shotgun was part of Lotus.
This tool wraps code in private Ruby namespace. Prefixing modules with ::OneFile fixes the problem.

Here updated code that works with v0.3.0.

# config.ru
require 'lotus'

module ::OneFile
  class Application < Lotus::Application
    configure do
      routes do
        get '/', to: 'home#index'
      end
    end
    load!
  end

  module Controllers
    module Home
      include OneFile::Controller

      class Index
        include OneFile::Action

        def call(params)
        end
      end
    end
  end

  module Views
    module Home
      class Index
        include OneFile::View

        def render
          "Hello, Lotus"
        end
      end
    end
  end
end

run ::OneFile::Application.new

#3