I'm creating a sinatra web app with a mongodb database. I use mongomapper to do the mappings. The web server is thin and I'm using slim as a templating language.
file ./config/config.ru:
$_DB_SERVER = "localhost"
$_APP_PATH = "~/Documents/Aptana_Workspace/Parameters_crud"
require 'bundler/setup'
Bundler.require(:default)
require "#{$_APP_PATH}/main.rb"
require "#{$_APP_PATH}/models/parameter.rb"
map '/' do
run CORE::Main
end
file main.rb:
module CORE
class Main < Sinatra::Base
use Rack::Flash
configure :development do
enable :sessions, :logging, :dump_errors, :inline_templates
enable :methodoverride
set :root, $_APP_PATH
logger = Logger.new($stdout)
end
get '/' do
slim :index
end
end
end
END
error encountered:
Errno::ENOENT at /
No such file or directory - ~/Documents/Aptana_Workspace/Parameters_crud/views/index.slim
I'm 100% sure this file does exist. What could be the cause of this error? If you need more information, please leave a comment...
Try using File.expand_path
like this -
$_APP_PATH = File.expand_path("~/Documents/Aptana_Workspace/Parameters_crud", __FILE__)