我正在使用站点地图生成器来生成我的站点地图。我已经在本地测试了我的所有代码,并准备在在线网络服务器上尝试它,当我尝试刷新站点地图时发生了以下情况bundle exec rake sitemap:refresh
:
ActiveRecord::StatementInvalid: Could not find table 'settings'
在 sitemap.rb 中执行的代码:
SitemapGenerator::Sitemap.create do
settings = Settings.first
languages = []
languages << "en" if settings.lang_en
languages << "fr" if settings.lang_fr
languages << "nl" if settings.lang_nl
languages << "de" if settings.lang_de
end
网络服务器上控制台中相同代码的结果:
[1] pry(main)> settings = Settings.first
Settings Load (2.0ms) SELECT "settings".* FROM "settings" LIMIT 1
Settings::Translation Load (2.0ms) SELECT "setting_translations".* FROM "setting_translations" WHERE "setting_translations"."setting_id" = 1
#Output here
[2] pry(main)> languages = []
=> []
[3] pry(main)> languages << "en" if settings.lang_en
=> nil
[4] pry(main)> languages << "fr" if settings.lang_fr
=> ["fr"]
[5] pry(main)> languages << "nl" if settings.lang_nl
=> ["fr", "nl"]
[6] pry(main)> languages << "de" if settings.lang_de
=> nil
[7] pry(main)> languages
=> ["fr", "nl"]
完整错误:
rake aborted!
ActiveRecord::StatementInvalid: Could not find table 'settings'
/home/<customer_here>/apps/default/releases/324/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.18/lib/active_record/connection_adapters/sqlite_adapter.rb:472:in `table_structure'
/home/<customer_here>/apps/default/releases/324/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.18/lib/active_record/connection_adapters/sqlite_adapter.rb:346:in `columns'
/home/<customer_here>/apps/default/releases/324/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.18/lib/active_record/connection_adapters/schema_cache.rb:12:in `block in initialize'
/home/<customer_here>/apps/default/releases/324/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.18/lib/active_record/model_schema.rb:229:in `yield'
/home/<customer_here>/apps/default/releases/324/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.18/lib/active_record/model_schema.rb:229:in `default'
/home/<customer_here>/apps/default/releases/324/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.18/lib/active_record/model_schema.rb:229:in `columns'
/home/<customer_here>/apps/default/releases/324/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.18/lib/active_record/model_schema.rb:238:in `columns_hash'
/home/<customer_here>/apps/default/releases/324/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.18/lib/active_record/locking/optimistic.rb:131:in `locking_enabled?'
/home/<customer_here>/apps/default/releases/324/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.18/lib/active_record/relation.rb:170:in `exec_queries'
/home/<customer_here>/apps/default/releases/324/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.18/lib/active_record/relation.rb:160:in `block in to_a'
/home/<customer_here>/apps/default/releases/324/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.18/lib/active_record/explain.rb:34:in `logging_query_plan'
/home/<customer_here>/apps/default/releases/324/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.18/lib/active_record/relation.rb:159:in `to_a'
/home/<customer_here>/apps/default/releases/324/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.18/lib/active_record/relation/finder_methods.rb:381:in `find_first'
/home/<customer_here>/apps/default/releases/324/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.18/lib/active_record/relation/finder_methods.rb:122:in `first'
/home/<customer_here>/apps/default/releases/324/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.18/lib/active_record/querying.rb:5:in `first'
/home/<customer_here>/apps/default/releases/324/config/sitemap.rb:8:in `block in run'
/home/<customer_here>/apps/default/releases/324/vendor/bundle/ruby/1.9.1/gems/sitemap_generator-5.0.5/lib/sitemap_generator/interpreter.rb:59:in `instance_eval'
/home/<customer_here>/apps/default/releases/324/vendor/bundle/ruby/1.9.1/gems/sitemap_generator-5.0.5/lib/sitemap_generator/interpreter.rb:59:in `eval'
/home/<customer_here>/apps/default/releases/324/vendor/bundle/ruby/1.9.1/gems/sitemap_generator-5.0.5/lib/sitemap_generator/link_set.rb:40:in `create'
/home/<customer_here>/apps/default/releases/324/vendor/bundle/ruby/1.9.1/gems/sitemap_generator-5.0.5/lib/sitemap_generator.rb:42:in `method_missing'
/home/<customer_here>/apps/default/releases/324/config/sitemap.rb:5:in `run'
/home/<customer_here>/apps/default/releases/324/vendor/bundle/ruby/1.9.1/gems/sitemap_generator-5.0.5/lib/sitemap_generator/interpreter.rb:76:in `instance_eval'
/home/<customer_here>/apps/default/releases/324/vendor/bundle/ruby/1.9.1/gems/sitemap_generator-5.0.5/lib/sitemap_generator/interpreter.rb:76:in `run'
/home/<customer_here>/apps/default/releases/324/vendor/bundle/ruby/1.9.1/gems/sitemap_generator-5.0.5/lib/sitemap_generator/tasks.rb:51:in `block (2 levels) in <top (required)>'
Tasks: TOP => sitemap:refresh => sitemap:create
(See full trace by running task with --trace)
使用的宝石:https ://github.com/kjvarga/sitemap_generator
操作系统:Mac OS X 10.9.4
Rails 版本:Rails 3.2.18
红宝石版本:红宝石 1.9.3p484
亲切的问候。
EDIT1:试图更改变量设置 - 同样的错误
langu_settings = Settings.first
languages = []
languages << "en" if langu_settings.lang_en
languages << "fr" if langu_settings.lang_fr
languages << "nl" if langu_settings.lang_nl
languages << "de" if langu_settings.lang_de