Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/apache-kafka/3.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 当我在heroku数据库上部署项目时,数据库无法正常工作_Ruby On Rails_Ruby_Heroku - Fatal编程技术网

Ruby on rails 当我在heroku数据库上部署项目时,数据库无法正常工作

Ruby on rails 当我在heroku数据库上部署项目时,数据库无法正常工作,ruby-on-rails,ruby,heroku,Ruby On Rails,Ruby,Heroku,所以我有这个代码在我的模式 # == Schema Information # # Table name: users # # id :integer not null, primary key # name :string # surname :string # user_id :integer # count :integer default(0) # was :boolean

所以我有这个代码在我的模式

# == Schema Information
#
# Table name: users
#
#  id         :integer          not null, primary key
#  name       :string
#  surname    :string
#  user_id    :integer
#  count      :integer          default(0)
#  was        :boolean          default(FALSE)
#  qrcode     :string
#  created_at :datetime         not null
#  updated_at :datetime         not null
#

class User < ApplicationRecord
    validates :name, presence: true
    validates :surname, presence: true
    validates :user_id, presence: true
    after_create :generate_qr

    private
    def generate_qr
        ian = User.find(id)
        ian.update_attribute(:qrcode, "https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=" + user_id.to_s)
        # update_attribute(:qrcode, "https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=" + user_id.to_s)
    end


end
工作正常,在本地主机上生成二维码。但是当我在heroku上部署时,我在heroku日志中有这个错误

2018-06-30T14:23:37.200657+00:00 app[web.1]: I, [2018-06-30T14:23:37.200507 #4]  INFO -- : [56b953ac-5a43-4b25-980d-f2bc5c53883a]   Parameters: {"utf8"=>"✓", "authenticity_token"=>"mBkhE7alyyKGtS4v+tnW2Vpg6c1z0kwQfbnftqTWdSukTpre29vkqVmeuVoGR7NJzs0EoxiQv0rS+WzJ4hUSOw==", "user"=>{"name"=>"fdsfds", "surname"=>"fdsfdsfds", "user_id"=>"53454"}, "commit"=>"Create User"}
2018-06-30T14:23:37.204598+00:00 app[web.1]: D, [2018-06-30T14:23:37.204527 #4] DEBUG -- : [56b953ac-5a43-4b25-980d-f2bc5c53883a]    (1.1ms)  BEGIN
2018-06-30T14:23:37.207575+00:00 app[web.1]: D, [2018-06-30T14:23:37.207496 #4] DEBUG -- : [56b953ac-5a43-4b25-980d-f2bc5c53883a]   User Create (1.5ms)  INSERT INTO "users" ("name", "surname", "user_id", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id"  [["name", "fdsfds"], ["surname", "fdsfdsfds"], ["user_id", 53454], ["created_at", "2018-06-30 14:23:37.204956"], ["updated_at", "2018-06-30 14:23:37.204956"]]
2018-06-30T14:23:37.214137+00:00 app[web.1]: D, [2018-06-30T14:23:37.214060 #4] DEBUG -- : [56b953ac-5a43-4b25-980d-f2bc5c53883a]   User Load (1.3ms)
  SELECT  "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2  [["id", 7], ["LIMIT", 1]]
2018-06-30T14:23:37.215729+00:00 app[web.1]: D, [2018-06-30T14:23:37.215664 #4] DEBUG -- : [56b953ac-5a43-4b25-980d-f2bc5c53883a]    (1.1ms)  ROLLBACK
2018-06-30T14:23:37.224955+00:00 app[web.1]: I, [2018-06-30T14:23:37.224881 #4]  INFO -- : [56b953ac-5a43-4b25-980d-f2bc5c53883a] Completed 500 Internal Server Error in 24ms (ActiveRecord: 6.1ms)
2018-06-30T14:23:37.225904+00:00 app[web.1]: F, [2018-06-30T14:23:37.225838 #4] FATAL -- : [56b953ac-5a43-4b25-980d-f2bc5c53883a]
2018-06-30T14:23:37.226043+00:00 app[web.1]: F, [2018-06-30T14:23:37.225990 #4] FATAL -- : [56b953ac-5a43-4b25-980d-f2bc5c53883a] NoMethodError (undefined method `qrcode=' for #<User:0x00000004fd1d68>):
2018-06-30T14:23:37.226091+00:00 app[web.1]: F, [2018-06-30T14:23:37.226046 #4] FATAL -- : [56b953ac-5a43-4b25-980d-f2bc5c53883a]
2018-06-30T14:23:37.226146+00:00 app[web.1]: F, [2018-06-30T14:23:37.226103 #4] FATAL -- : [56b953ac-5a43-4b25-980d-f2bc5c53883a] app/models/user.rb:25:in `generate_qr'

有人请帮忙。我不知道哪里出错了。它在我的本地主机上运行正常。

似乎您没有在heroku上运行迁移。请尝试heroku run rake db:migrate和其他应用程序配置以及您所处的任何环境。