我正在阅读Daniel Kehoe撰写的“Learn Ruby on Rails”一书。我似乎无法超越第10章的开头,第11章的开头,我在开发中发现应用程序服务器.rb
这是输出:
=> Booting WEBrick
=> Rails 4.2.5 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Exiting
/Users/adrian/workspace/learn-rails/config/environments/development.rb:67:in `block in <top (required)>': uninitialized constant ActiveSupport::EventedFileUpdateChecker (NameError)
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/railtie.rb:210:in `instance_eval'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/railtie.rb:210:in `configure'
from /Users/adrian/workspace/learn-rails/config/environments/development.rb:1:in `<top (required)>'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/engine.rb:598:in `block (2 levels) in <class:Engine>'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/engine.rb:597:in `each'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/engine.rb:597:in `block in <class:Engine>'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/initializable.rb:30:in `run'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/adrian/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:228:in `block in tsort_each'
from /Users/adrian/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
from /Users/adrian/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
from /Users/adrian/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:431:in `each_strongly_connected_component_from'
from /Users/adrian/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/initializable.rb:44:in `each'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/initializable.rb:44:in `tsort_each_child'
from /Users/adrian/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:415:in `call'
from /Users/adrian/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:415:in `each_strongly_connected_component_from'
from /Users/adrian/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:349:in `block in each_strongly_connected_component'
from /Users/adrian/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:347:in `each'
from /Users/adrian/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:347:in `call'
from /Users/adrian/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:347:in `each_strongly_connected_component'
from /Users/adrian/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:226:in `tsort_each'
from /Users/adrian/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:205:in `tsort_each'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/application.rb:352:in `initialize!'
from /Users/adrian/workspace/learn-rails/config/environment.rb:5:in `<top (required)>'
from /Users/adrian/workspace/learn-rails/config.ru:3:in `require_relative'
from /Users/adrian/workspace/learn-rails/config.ru:3:in `block in <main>'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/rack-1.6.4/lib/rack/builder.rb:55:in `instance_eval'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/rack-1.6.4/lib/rack/builder.rb:55:in `initialize'
from /Users/adrian/workspace/learn-rails/config.ru:in `new'
from /Users/adrian/workspace/learn-rails/config.ru:in `<main>'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/rack-1.6.4/lib/rack/builder.rb:49:in `eval'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/rack-1.6.4/lib/rack/builder.rb:49:in `new_from_string'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/rack-1.6.4/lib/rack/builder.rb:40:in `parse_file'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/rack-1.6.4/lib/rack/server.rb:299:in `build_app_and_options_from_config'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/rack-1.6.4/lib/rack/server.rb:208:in `app'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/commands/server.rb:61:in `app'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/rack-1.6.4/lib/rack/server.rb:336:in `wrapped_app'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/commands/server.rb:139:in `log_to_stdout'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/commands/server.rb:78:in `start'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:80:in `block in server'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:75:in `tap'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:75:in `server'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/commands.rb:17:in `<top (required)>'
from /Users/adrian/workspace/learn-rails/bin/rails:9:in `require'
from /Users/adrian/workspace/learn-rails/bin/rails:9:in `<top (required)>'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/spring-1.7.2/lib/spring/client/rails.rb:28:in `load'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/spring-1.7.2/lib/spring/client/rails.rb:28:in `call'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/spring-1.7.2/lib/spring/client/command.rb:7:in `call'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/spring-1.7.2/lib/spring/client.rb:30:in `run'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/spring-1.7.2/bin/spring:49:in `<top (required)>'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/spring-1.7.2/lib/spring/binstub.rb:11:in `load'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/spring-1.7.2/lib/spring/binstub.rb:11:in `<top (required)>'
from /Users/adrian/workspace/learn-rails/bin/spring:13:in `require'
from /Users/adrian/workspace/learn-rails/bin/spring:13:in `<top (required)>'
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'
现在,我在提交之前已经做了很多研究,其他人也有类似的问题,即http://stackoverflow.com/questions/37796350/syntaxis-error-when-start-rails-server-after-first-configuration,但这些问题与使用config / secrets.yml文件的ENV错误有关。
我还看到了删除development.rb中的以下行的建议:
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
但这似乎没有帮助,只给我以下错误信息:
Booting WEBrick
=> Rails 4.2.5 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Exiting
/Users/adrian/workspace/learn-rails/config/initializers/new_framework_defaults.rb:15:in `<top (required)>': undefined method `to_time_preserves_timezone=' for ActiveSupport:Module (NoMethodError)
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:268:in `load'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:268:in `block in load'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:240:in `load_dependency'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:268:in `load'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/engine.rb:652:in `block in load_config_initializer'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/activesupport-4.2.5/lib/active_support/notifications.rb:166:in `instrument'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/engine.rb:651:in `load_config_initializer'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/engine.rb:616:in `block (2 levels) in <class:Engine>'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/engine.rb:615:in `each'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/engine.rb:615:in `block in <class:Engine>'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/initializable.rb:30:in `run'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/adrian/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:228:in `block in tsort_each'
from /Users/adrian/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
from /Users/adrian/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
from /Users/adrian/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:431:in `each_strongly_connected_component_from'
from /Users/adrian/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/initializable.rb:44:in `each'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/initializable.rb:44:in `tsort_each_child'
from /Users/adrian/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:415:in `call'
from /Users/adrian/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:415:in `each_strongly_connected_component_from'
from /Users/adrian/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:349:in `block in each_strongly_connected_component'
from /Users/adrian/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:347:in `each'
from /Users/adrian/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:347:in `call'
from /Users/adrian/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:347:in `each_strongly_connected_component'
from /Users/adrian/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:226:in `tsort_each'
from /Users/adrian/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:205:in `tsort_each'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/application.rb:352:in `initialize!'
from /Users/adrian/workspace/learn-rails/config/environment.rb:5:in `<top (required)>'
from /Users/adrian/workspace/learn-rails/config.ru:3:in `require_relative'
from /Users/adrian/workspace/learn-rails/config.ru:3:in `block in <main>'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/rack-1.6.4/lib/rack/builder.rb:55:in `instance_eval'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/rack-1.6.4/lib/rack/builder.rb:55:in `initialize'
from /Users/adrian/workspace/learn-rails/config.ru:in `new'
from /Users/adrian/workspace/learn-rails/config.ru:in `<main>'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/rack-1.6.4/lib/rack/builder.rb:49:in `eval'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/rack-1.6.4/lib/rack/builder.rb:49:in `new_from_string'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/rack-1.6.4/lib/rack/builder.rb:40:in `parse_file'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/rack-1.6.4/lib/rack/server.rb:299:in `build_app_and_options_from_config'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/rack-1.6.4/lib/rack/server.rb:208:in `app'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/commands/server.rb:61:in `app'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/rack-1.6.4/lib/rack/server.rb:336:in `wrapped_app'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/commands/server.rb:139:in `log_to_stdout'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/commands/server.rb:78:in `start'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:80:in `block in server'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:75:in `tap'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:75:in `server'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/commands.rb:17:in `<top (required)>'
from /Users/adrian/workspace/learn-rails/bin/rails:9:in `require'
from /Users/adrian/workspace/learn-rails/bin/rails:9:in `<top (required)>'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/spring-1.7.2/lib/spring/client/rails.rb:28:in `load'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/spring-1.7.2/lib/spring/client/rails.rb:28:in `call'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/spring-1.7.2/lib/spring/client/command.rb:7:in `call'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/spring-1.7.2/lib/spring/client.rb:30:in `run'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/spring-1.7.2/bin/spring:49:in `<top (required)>'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/spring-1.7.2/lib/spring/binstub.rb:11:in `load'
from /Users/adrian/.rvm/gems/ruby-2.3.1@learn-rails/gems/spring-1.7.2/lib/spring/binstub.rb:11:in `<top (required)>'
from /Users/adrian/workspace/learn-rails/bin/spring:13:in `require'
from /Users/adrian/workspace/learn-rails/bin/spring:13:in `<top (required)>'
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'
以下是我的development.rb文件的内容:
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Do not eager load code on boot.
config.eager_load = false
# Show full error reports.
config.consider_all_requests_local = true
# Enable/disable caching. By default caching is disabled.
if Rails.root.join('tmp/caching-dev.txt').exist?
config.action_controller.perform_caching = true
config.cache_store = :memory_store
config.public_file_server.headers = {
'Cache-Control' => 'public, max-age=172800'
}
else
config.action_controller.perform_caching = false
config.cache_store = :null_store
end
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
config.action_mailer.perform_caching = false
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true
config.action_mailer.smtp_settings = {
address: "smtp.sendgrid.net",
port: 587,
domain: Rails.application.secrets.domain_name,
authentication: "plain",
user_name: Rails.application.secrets.email_provider_username,
password: Rails.application.secrets.email_provider_password
}
# ActionMailer Config
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.raise_delivery_errors = true
# Send email in development mode?
config.action_mailer.perform_deliveries = true
# Suppress logger output for asset requests.
config.assets.quiet = true
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
end
对此非常沮丧,我正在按照教程进行操作。我真的很难过我为创造这个错误做了什么......
任何帮助将不胜感激!
编辑:我最终删除了并再次启动了教程。这次我指定了我想安装的确切rails版本(按照教程)而不是安装最新版本。答案 0 :(得分:0)
您需要将data-ng-pattern="/(^([a-zA-Z]){2}([0-9]){6})|([0-9]*)?$/"
gem添加到您的Gemfile(最好是在开发组中)并运行listen
。
答案 1 :(得分:0)
通常会发生这种情况,因为您安装的Rails版本比.railsrc
或template.rb
中要求的版本更新。
如果是这种情况,当您运行rails new my_new_app
时,默认情况下会使用最新版本来处理该过程的早期步骤,但是一旦安装了模板/ railsrc版本,后面的步骤就会使用此版本。这会导致兼容性问题。
您可以通过将rails -v
(在您调用rails new
的目录中)的输出与.railsrc
或{{{{}}中的内容进行比较来验证这是您的问题。 1}}。如果它们不同,可以轻松解决:
重新创建您的Rails应用,在命令行调用中从template.rb
或.railsrc
指定相同的Rails版本:
template.rb