I'm new to the ruby world, and Sinatra for that matter, so I have no choice but to ask here about the error I keep getting.
I'm using a combination of Rack + Sinatra with Slim as template engine. I have my app.rb
setup as this:
module Pulsr
class StylusHandler < Sinatra::Base
set :views, File.dirname(__FILE__) + '/stylus'
get '/css/styles.css' do
stylus :styles
end
end
class Application < Sinatra::Base
register Sinatra::ConfigFile
config_file './config/config.yml'
use Pulsr::Api
use Pulsr::Routes
enable :logging, :dump_errors if Sinatra::Base.development?
disable :method_override, :run
set :public_folder, File.join(:root.to_s, 'static')
set :views, File.join(:root.to_s, 'views')
#set :static_cache_control, [:public, max_age: 60 * 60 * 24 * 365] if Sinatra::Base.production?
end
end
And the Pulsr::Api
and Pulsr::Routes
are in two different files in a subdirectory. The issue I have is that slim tries to render the template relative to the path of the routes file, which looks like this:
module Pulsr
class Routes < Sinatra::Base
get '/*' do
slim :index
end
end
end
So, my folder structure looks something like this:
- config
- config.yml
...
- controllers
- routes.rb
- views
- index.slim
- app.rb
- config.ru
- Gemfile
...
I get this error: No such file or directory @ rb_sysopen - /Users/rolandjitsu/Projects/Products/pulsr/controllers/views/index.slim
where the template is actually placed with one level up in the views
folder.
Before I had all the code in the app.rb
file, and , normally, it worked, but now I am unsure how to fix this path issue.