You have set up your Routes
class as a separate Sinatra application from your main app, and this means it has its own settings that are not shared. The views folder for the Routes
app is therefore the default for that app, which is the the views
directory inside the controllers
directory.
The simple way to fix it would be to specify the views
directory in the Routes
class.
module Pulsr
class Routes < Sinatra::Base
# add this line
set :views, File.expand_path(File.join(__FILE__, '../../views'))
get '/*' do
slim :index
end
end
You could also set the app_file
to be the main app file, the views
, root
and public_folder
settings will all then be set based on that.
It looks like you don’t actually intend to create several separate applications, but rather split up your single app into several files. A possibly better way to do that would be to use extensions
. You can create a module containing routes that you can include in your main application, and they will use the same settings as the main app.
module Routes # N.B modle not class
# in this method you can add routes to the main app
def self.registered(app)
# you need to use 'app.get', not plain 'get'
app.get '/*' do
slim :index
end
end
end
Then in your main app call register Routes
instead of use Routes
. This is slightly more work to set up, but gives you more flexibility.