2015-08-17 38 views
0

當我在使用rake進行數據庫遷移後運行'rackup'命令時,出現了這個錯誤,我不明白這是什麼意思。active_record有問題

C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/activerecord-4.2.3/lib/active_record/railties/databases.rake:3:in `<top (required)>': undefined method `namespace' for main:Object (NoMethodError) 
    from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:268:in `load' 
    from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:268:in `block in load' 
    from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:240:in `load_dependency' 
    from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:268:in `load' 
    from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/sinatra-activerecord-2.0.6/lib/sinatra/activerecord/rake.rb:1:in `<top (required)>' 
    from C:/RailsInstaller/Ruby2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:69:in `require' 
    from C:/RailsInstaller/Ruby2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:69:in `require' 
    from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `block in require' 
    from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:240:in `load_dependency' 
    from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `require' 
    from C:/wamp/www/sinatra-template-master/config.ru:2:in `block in <main>' 
    from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.6.4/lib/rack/builder.rb:55:in `instance_eval' 
    from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.6.4/lib/rack/builder.rb:55:in `initialize' 
    from C:/wamp/www/sinatra-template-master/config.ru:in `new' 
    from C:/wamp/www/sinatra-template-master/config.ru:in `<main>' 
    from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.6.4/lib/rack/builder.rb:49:in `eval' 
    from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.6.4/lib/rack/builder.rb:49:in `new_from_string' 
    from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.6.4/lib/rack/builder.rb:40:in `parse_file' 
    from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.6.4/lib/rack/server.rb:299:in `build_app_and_options_from_config' 
    from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.6.4/lib/rack/server.rb:208:in `app' 
    from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.6.4/lib/rack/server.rb:336:in `wrapped_app' 
    from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.6.4/lib/rack/server.rb:272:in `start' 
    from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.6.4/lib/rack/server.rb:147:in `start' 
    from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rack-1.6.4/bin/rackup:4:in `<top (required)>' 
    from C:/RailsInstaller/Ruby2.1.0/bin/rackup:23:in `load' 
    from C:/RailsInstaller/Ruby2.1.0/bin/rackup:23:in `<main>' 

請幫助,謝謝!

我有這個在我的config.ru文件

require './app' 
require 'sinatra/activerecord/rake' 

run Sinatra::Application 
+3

沒有看到'C:/ wamp/www/sinatra-template-master/config.ru'的代碼,我們忍不住。 – mudasobwa

+0

您是否意外地要求您的'Rakefile'或您的任何rake任務定義到您的'config.ru'? – Aetherus

+0

噢,我想我可能有.. – Macbhee

回答

1

我試圖做同樣的config.ru。當我刪除

需要 '西納特拉/的ActiveRecord /耙'

一切都開始工作。

方法「名稱空間」在rake/dsl_definition.rb中定義。因此,擴展Sinatra :: Base的應用程序沒有看到它。