这是我第一次在生产环境中启动rails应用程序。我先跑rails server -e production
然后得到了密钥。之后我运行了这一行bundle exec rake assets:precompile db:migrate RAILS_ENV=production
。一旦我运行该行,我再次运行rails server -e production
我的终端中出现以下错误(请参阅最后4行)以及浏览器中的404错误页面:
krav@krav-Q534UXK:~/Desktop/cnd$ rails server -e production
=> Booting Puma
=> Rails 5.1.3 application starting in production on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.10.0 (ruby 2.3.3-p222), codename: Russell's Teapot
* Min threads: 5, max threads: 5
* Environment: production
* Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop
/home/krav/Desktop/cnd/app/views/creatives/index.html.erb:20: warning: key :data is duplicated and overwritten on line 20
/home/krav/Desktop/cnd/app/views/creatives/index.html.erb:20: warning: key :data is duplicated and overwritten on line 20
/home/krav/Desktop/cnd/app/views/creatives/index.html.erb:107: warning: key :data is duplicated and overwritten on line 107
/home/krav/Desktop/cnd/app/views/creatives/index.html.erb:107: warning: key :data is duplicated and overwritten on line 107
当我到这里发出错误的行时,他们分别是:
第20行
<%= image_tag "AdobeStock_95578405.jpeg" ,alt: "slidebg1", :data => {bgposition: "center bottom"} , :data => {bgrepeat: "no-repeat"} ,:data => {bgfit: "cover"} , :class => "rev-slidebg" %>
第107行
<%= image_tag "AdobeStock_108067927.jpeg" ,alt: "slidebg1", :data => {bgposition: "center bottom"} , :data => {bgrepeat: "no-repeat"} ,:data => {bgfit: "cover"} , :class => "rev-slidebg" %>
在开发中,这很好用。我无法弄清楚为什么这些行会给我一个错误并且不允许Web应用程序启动它们看起来正确并让我在开发模式下看到我需要的外观。
答案 0 :(得分:1)
这些行中有重复的数据键,只能有一行:
即。这个:
<%= image_tag "AdobeStock_95578405.jpeg" ,alt: "slidebg1", :data => {bgposition: "center bottom"} , :data => {bgrepeat: "no-repeat"} ,:data => {bgfit: "cover"} , :class => "rev-slidebg" %>
应为:<%= image_tag "AdobeStock_95578405.jpeg" ,alt: "slidebg1", :data => {bgposition: "center bottom",bgrepeat: "no-repeat", bgfit: "cover"} , :class => "rev-slidebg" %>