为什么我在 heroku 上收到此错误,但在 rails 应用程序的开发中却没有?
Why am I getting this error on heroku but not in development in my rails app?
我的 heroku 日志中出现此错误:
这是我的 pins_controller
中的创建方法
def create
code = params[:pin][:code]
@classroom = Classroom.where('code LIKE ?', code).first
unless @classroom
flash[:error] = "Classroom code incorrect"
render :new
else
params[:pin][:classroom_id] = @classroom.id
end
@pin = Pin.new(pin_params)
@pin.save
params[:pin][:emotion_ids].each do |emotion_id|
@emotion = Emotion.find(emotion_id)
@pin.emotions << @emotion
end
respond_with(@pin)
authorize @pin
end
我最近在暂存 url 和产品 url(指向我的域)上创建了我的应用程序的新实例,我 运行 耙 db:migrate 这样应该可以正常工作,网站上的大多数其他功能都很好。
为什么这会在本地工作而不是在 heroku 中?
感谢您的帮助。
可能是因为您只是 运行 迁移,所以您还没有播种数据库。如果您的开发环境中的数据库中有情感对象,它们将不会出现在您的 heroku 生产环境中。也许创建一个种子文件,向其中添加一些情绪,然后查看错误是否仍然存在。在 heroku 上似乎不是问题,只是当您调用每个对象时似乎缺少一个对象。
确保你的数据库中有一些情绪。
我的 heroku 日志中出现此错误:
这是我的 pins_controller
中的创建方法def create
code = params[:pin][:code]
@classroom = Classroom.where('code LIKE ?', code).first
unless @classroom
flash[:error] = "Classroom code incorrect"
render :new
else
params[:pin][:classroom_id] = @classroom.id
end
@pin = Pin.new(pin_params)
@pin.save
params[:pin][:emotion_ids].each do |emotion_id|
@emotion = Emotion.find(emotion_id)
@pin.emotions << @emotion
end
respond_with(@pin)
authorize @pin
end
我最近在暂存 url 和产品 url(指向我的域)上创建了我的应用程序的新实例,我 运行 耙 db:migrate 这样应该可以正常工作,网站上的大多数其他功能都很好。
为什么这会在本地工作而不是在 heroku 中?
感谢您的帮助。
可能是因为您只是 运行 迁移,所以您还没有播种数据库。如果您的开发环境中的数据库中有情感对象,它们将不会出现在您的 heroku 生产环境中。也许创建一个种子文件,向其中添加一些情绪,然后查看错误是否仍然存在。在 heroku 上似乎不是问题,只是当您调用每个对象时似乎缺少一个对象。
确保你的数据库中有一些情绪。