I'm creating a Ruby app, and when I try to run it, I get an error saying it cannot load a file.
In my main file, app.rb, I'm trying to require models/issue
require "models/issue"
class App < Sinatra::Base
enable :sessions
register Sinatra::Flash
get "/" do
"redirect/issues"
end
get "/issues" do
@issues = Issue.all
haml :"issues/index"
end
end
When I use shotgun, I get the following error:
Boot Error
Something went wrong while loading config.ru
LoadError: cannot load such file -- models/issue
/Users/kristinerooks/Desktop/issuetracker/lib/app.rb:1:in `require'
/Users/kristinerooks/Desktop/issuetracker/lib/app.rb:1:in `<top (required)>'
config.ru:2:in `require'
config.ru:2:in `block in inner_app'
/Users/kristinerooks/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/builder.rb:55:in `instance_eval'
/Users/kristinerooks/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/builder.rb:55:in `initialize'
config.ru:1:in `new'
config.ru:1:in `inner_app'
/Users/kristinerooks/.rvm/gems/ruby-2.2.1/gems/shotgun-0.9.1/lib/shotgun/loader.rb:113:in `eval'
/Users/kristinerooks/.rvm/gems/ruby-2.2.1/gems/shotgun-0.9.1/lib/shotgun/loader.rb:113:in `inner_app'
/Users/kristinerooks/.rvm/gems/ruby-2.2.1/gems/shotgun-0.9.1/lib/shotgun/loader.rb:103:in `assemble_app'
/Users/kristinerooks/.rvm/gems/ruby-2.2.1/gems/shotgun-0.9.1/lib/shotgun/loader.rb:86:in `proceed_as_child'
/Users/kristinerooks/.rvm/gems/ruby-2.2.1/gems/shotgun-0.9.1/lib/shotgun/loader.rb:31:in `call!'
/Users/kristinerooks/.rvm/gems/ruby-2.2.1/gems/shotgun-0.9.1/lib/shotgun/loader.rb:18:in `call'
/Users/kristinerooks/.rvm/gems/ruby-2.2.1/gems/shotgun-0.9.1/lib/shotgun/favicon.rb:12:in `call'
/Users/kristinerooks/.rvm/gems/ruby-2.2.1/gems/shotgun-0.9.1/lib/shotgun/static.rb:14:in `call'
/Users/kristinerooks/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/urlmap.rb:66:in `block in call'
/Users/kristinerooks/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/urlmap.rb:50:in `each'
/Users/kristinerooks/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/urlmap.rb:50:in `call'
/Users/kristinerooks/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/builder.rb:153:in `call'
/Users/kristinerooks/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/handler/webrick.rb:88:in `service'
/Users/kristinerooks/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/httpserver.rb:138:in `service'
/Users/kristinerooks/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/httpserver.rb:94:in `run'
/Users/kristinerooks/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/server.rb:294:in `block in start_thread'
I don't think there's a problem with the file path. My path looks like this:
ProjectName
config.ru
lib
app.rb
models
issue.rb
Here is my config.ru file:
require "./env"
require "./lib/app"
run App
And here is my models/issue file:
class Issue
include Mongoid::Document
include Mongoid::Timestamps::Updated
field :name, type: String
field :description, type: String
end
Does
require_relative 'models/issue'
or
require './models/issue'
help?