该应用程序在本地运行良好。要使用它,我必须先将其播种。
尝试部署,我得到了以下信息:
INFO [b83023c5] Running ~/.rvm/bin/rvm default do bundle exec rake assets:precompile as deploy@51.254.129.78
DEBUG [b83023c5] Command: cd /home/deploy/guialocal/releases/20180714191701 && ( export RAILS_ENV="production" RAILS_GROUPS="" ; ~/.rvm/bin/rvm default do bundle exec rake assets:precompile )
DEBUG [b83023c5] rake aborted!
DEBUG [b83023c5] ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "configs" does not exist
LINE 1: SELECT "configs".* FROM "configs" ORDER BY "configs"."id" A...
^
: SELECT "configs".* FROM "configs" ORDER BY "configs"."id" ASC LIMIT $1
DEBUG [b83023c5] /home/deploy/guialocal/shared/bundle/ruby/2.4.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/postgresql_adapter.rb:659:in `prepare'
config表是一个只有1条记录的表,我通过初始化程序使用这些表将信息加载到我在每个VPS部署实例和所有应用程序中使用的全局变量中。
db / migrate / 20180531033550_create_configs.rb
class CreateConfigs < ActiveRecord::Migration[5.0]
def change
create_table :configs do |t|
t.integer :city
t.timestamps
end
end
end
db / seeds.rb
Config.create!(
city: "city_name"
)
config / initializers / instance_configs.rb
$current_city = Config.try(:first).try(:city)
答案 0 :(得分:0)
问题在于,在初始化程序中,您无法执行BD操作(尚不可用)。在mi的情况下,我删除了使用helper_method的分配,以便在所有内容完全加载后获取信息。