Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/53.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails rails的命令错误_Ruby On Rails - Fatal编程技术网

Ruby on rails rails的命令错误

Ruby on rails rails的命令错误,ruby-on-rails,Ruby On Rails,当我发出命令rails s时,会出现以下错误消息: nathan@Nathan-Ubuntu:~/Documents/Aptana Studio 3 Workspace/sample_application/app/controllers$ rails s => Booting WEBrick => Rails 3.2.8 application starting in development on http://0.0.0.0:3000 => Call with -d t

当我发出命令
rails s
时,会出现以下错误消息:

  nathan@Nathan-Ubuntu:~/Documents/Aptana Studio 3 Workspace/sample_application/app/controllers$ rails s
=> Booting WEBrick
=> Rails 3.2.8 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/home/nathan/Documents/Aptana Studio 3 Workspace/sample_application/config/routes.rb:1:in `<top (required)>': uninitialized constant SampleApp (Name
Error)
        from /home/nathan/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
        from /home/nathan/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/application/routes_reloader.rb:40:in `each'
        from /home/nathan/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/application/routes_reloader.rb:40:in `load_paths'
        from /home/nathan/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/application/routes_reloader.rb:16:in `reload!'
        from /home/nathan/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/application/routes_reloader.rb:26:in `block in updater'
        from /home/nathan/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/file_update_checker.rb:78:in `call'
        from /home/nathan/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/file_update_checker.rb:78:in `execute'
        from /home/nathan/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/application/routes_reloader.rb:27:in `updater'
        from /home/nathan/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/application/routes_reloader.rb:7:in `execute_if_updated'
        from /home/nathan/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/application/finisher.rb:66:in `block in <module:Finisher>'
        from /home/nathan/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/initializable.rb:30:in `instance_exec'
        from /home/nathan/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/initializable.rb:30:in `run'
        from /home/nathan/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/initializable.rb:55:in `block in run_initializers'
        from /home/nathan/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/initializable.rb:54:in `each'
        from /home/nathan/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/initializable.rb:54:in `run_initializers'
        from /home/nathan/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/application.rb:136:in `initialize!'
        from /home/nathan/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/railtie/configurable.rb:30:in `method_missing'
        from /home/nathan/Documents/Aptana Studio 3 Workspace/sample_application/config/environment.rb:5:in `<top (required)>'
        from /home/nathan/Documents/Aptana Studio 3 Workspace/sample_application/config.ru:4:in `require'
        from /home/nathan/Documents/Aptana Studio 3 Workspace/sample_application/config.ru:4:in `block in <main>'
        from /home/nathan/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval'
        from /home/nathan/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize'
        from /home/nathan/Documents/Aptana Studio 3 Workspace/sample_application/config.ru:1:in `new'
        from /home/nathan/Documents/Aptana Studio 3 Workspace/sample_application/config.ru:1:in `<main>'
        from /home/nathan/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/builder.rb:40:in `eval'
        from /home/nathan/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/builder.rb:40:in `parse_file'
        from /home/nathan/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/server.rb:200:in `app'
        from /home/nathan/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/commands/server.rb:46:in `app'
        from /home/nathan/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/server.rb:301:in `wrapped_app'
        from /home/nathan/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/server.rb:252:in `start'
        from /home/nathan/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/commands/server.rb:70:in `start'
        from /home/nathan/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/commands.rb:55:in `block in <top (required)>'
        from /home/nathan/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/commands.rb:50:in `tap'
        from /home/nathan/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/commands.rb:50:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'
config/application.rb
需要文件。展开路径('../boot',文件)
需要“rails/all”
如果定义?(捆绑机)
#如果在部署到生产环境之前预编译资产,请使用此行
Bundler.require(*Rails.groups(:资产=>%w(开发测试)))
#如果您希望在生产中惰性地编译资产,请使用此行
#Bundler.require(:default,:assets,Rails.env)
结束
模块采样应用
类应用程序
更新:检查路线后

SampleApp
更改为
SampleApplication

查看您的
跟踪
应用程序路径
名称如果应用程序是

sample\u应用程序
因此应用程序名称应为
SampleApplication

但是从跟踪来看,它似乎是作为
SampleApp

这可能是因为您稍后重命名了应用程序

在学习过程中复制粘贴了一些教程

检查
config/envirnoment.rb文件,最后一行应该包含应用程序名称

差不多

SampleApplication::Application.initialize 

因此,示例中的应用程序名称是
SampleApplication

您的
config/routes.rb
应该以
SampleApplication::application.routes.draw do

开头,请发布routes.rb…和
config/application.rb
的内容@NathanDunn将来,请编辑您的问题以添加新代码,而不是发布链接。如果链接消失了,这个问题就没用了。
require File.expand_path('../boot', __FILE__)

require 'rails/all'

if defined?(Bundler)
  # If you precompile assets before deploying to production, use this line
  Bundler.require(*Rails.groups(:assets => %w(development test)))
  # If you want your assets lazily compiled in production, use this line
  # Bundler.require(:default, :assets, Rails.env)
end

module SampleApplication
  class Application < Rails::Application
    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration should go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded.

    # Custom directories with classes and modules you want to be autoloadable.
    # config.autoload_paths += %W(#{config.root}/extras)

    # Only load the plugins named here, in the order given (default is alphabetical).
    # :all can be used as a placeholder for all plugins not explicitly named.
    # config.plugins = [ :exception_notification, :ssl_requirement, :all ]

    # Activate observers that should always be running.
    # config.active_record.observers = :cacher, :garbage_collector, :forum_observer

    # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
    # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
    # config.time_zone = 'Central Time (US & Canada)'

    # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
    # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
    # config.i18n.default_locale = :de

    # Configure the default encoding used in templates for Ruby 1.9.
    config.encoding = "utf-8"

    # Configure sensitive parameters which will be filtered from the log file.
    config.filter_parameters += [:password]

    # Enable escaping HTML in JSON.
    config.active_support.escape_html_entities_in_json = true

    # Use SQL instead of Active Record's schema dumper when creating the database.
    # This is necessary if your schema can't be completely dumped by the schema dumper,
    # like if you have constraints or database-specific column types
    # config.active_record.schema_format = :sql

    # Enforce whitelist mode for mass assignment.
    # This will create an empty whitelist of attributes available for mass-assignment for all models
    # in your app. As such, your models will need to explicitly whitelist or blacklist accessible
    # parameters by using an attr_accessible or attr_protected declaration.
    config.active_record.whitelist_attributes = true

    # Enable the asset pipeline
    config.assets.enabled = true

    # Version of your assets, change this if you want to expire all your assets
    config.assets.version = '1.0'
  end
end
SampleApplication::Application.initialize