gpt4 book ai didi

ruby - Tux with Sinatra 无法加载

转载 作者:数据小太阳 更新时间:2023-10-29 08:49:06 26 4
gpt4 key购买 nike

Sinatra 的新手,但我正在按照本教程设置一个带有一些静态页面的简单博客站点:http://danneu.com/posts/15-a-simple-blog-with-sinatra-and-active-record-some-useful-tools/

我创建了包含以下内容的 gemfile:

# Gemfile
source :rubygems

gem "sinatra"
gem "sqlite3"
gem "activerecord"
gem "sinatra-activerecord"

group :development do
gem "shotgun"
gem "tux"
end

然后我使用bundle install安装

我的 config.ru 看起来像这样:

#config.ru
require "./app"
run Sinatra::Application

但是当我尝试运行 tux 时,出现以下错误:

/Users/admin/.rvm/gems/ruby-2.0.0-p195/gems/ripl-rack-0.2.0/lib/ripl/rack.rb:38:in `eval': cannot load such file -- ./app (LoadError)
from (eval):2:in `block in initialize'
from /Users/admin/.rvm/gems/ruby-2.0.0-p195/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
from /Users/admin/.rvm/gems/ruby-2.0.0-p195/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
from (eval):1:in `new'
from (eval):1:in `initialize'
from /Users/admin/.rvm/gems/ruby-2.0.0-p195/gems/ripl-rack-0.2.0/lib/ripl/rack.rb:38:in `eval'
from /Users/admin/.rvm/gems/ruby-2.0.0-p195/gems/ripl-rack-0.2.0/lib/ripl/rack.rb:38:in `initialize'
from /Users/admin/.rvm/gems/ruby-2.0.0-p195/gems/ripl-rack-0.2.0/lib/ripl/rack.rb:18:in `new'
from /Users/admin/.rvm/gems/ruby-2.0.0-p195/gems/ripl-rack-0.2.0/lib/ripl/rack.rb:18:in `rack'
from /Users/admin/.rvm/gems/ruby-2.0.0-p195/gems/ripl-rack-0.2.0/lib/ripl/rack.rb:9:in `before_loop'
from /Users/admin/.rvm/gems/ruby-2.0.0-p195/gems/ripl-multi_line-0.3.1/lib/ripl/multi_line.rb:18:in `before_loop'
from /Users/admin/.rvm/gems/ruby-2.0.0-p195/gems/ripl-0.7.0/lib/ripl/readline.rb:6:in `before_loop'
from /Users/admin/.rvm/gems/ruby-2.0.0-p195/gems/ripl-0.7.0/lib/ripl/completion.rb:5:in `before_loop'
from /Users/admin/.rvm/gems/ruby-2.0.0-p195/gems/ripl-0.7.0/lib/ripl/shell.rb:34:in `loop'
from /Users/admin/.rvm/gems/ruby-2.0.0-p195/gems/ripl-0.7.0/lib/ripl/runner.rb:49:in `start'
from /Users/admin/.rvm/gems/ruby-2.0.0-p195/gems/ripl-0.7.0/lib/ripl/runner.rb:31:in `run'
from /Users/admin/.rvm/gems/ruby-2.0.0-p195/gems/tux-0.3.0/bin/tux:7:in `<top (required)>'
from /Users/admin/.rvm/gems/ruby-2.0.0-p195/bin/tux:23:in `load'
from /Users/admin/.rvm/gems/ruby-2.0.0-p195/bin/tux:23:in `<main>'
from /Users/admin/.rvm/gems/ruby-2.0.0-p195/bin/ruby_noexec_wrapper:14:in `eval'
from /Users/admin/.rvm/gems/ruby-2.0.0-p195/bin/ruby_noexec_wrapper:14:in `<main>'

知道是什么原因造成的吗?我有 ruby 2.0.0p195(2013-05-14 修订版 40734)[x86_64-darwin12.4.0]

最佳答案

你的错误是这样的:

cannot load such file -- ./app (LoadError)

该错误表示 tux 在当前目录中找不到名为 app.rb 的文件。 tux 正在寻找该文件,因为您的 config.ru 是这样说的:

config.ru
require "./app"
run Sinatra::Application

看看它是如何提到名为“./app”的文件的?好吧,“教程”在显示 tux 的屏幕截图之前不会向您显示该文件的屏幕截图。所以创建 app.rb 文件,然后运行 ​​tux。

同时更改您的 Gemfile:

source :rubygems

为此:

source 'https://rubygems.org'

(当你执行 .../blog$ bundle install Bundler 应该给你一个警告。)

您将在后面遇到的另一个错误:

在晚礼服中,它说要这样做:

>> p = new_record?

应该是:

>> p.new_record?

关于ruby - Tux with Sinatra 无法加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18140867/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com