Heroku管道 - 在升级和扩展上的相同代码生产但生产中断

时间:2016-08-05 19:13:51

标签: ruby-on-rails ruby heroku

我是Rails(和Heroku)的新手,并且一直在使用管道进行部署。我假设两个环境都是相同的 - 我使用一个用于登台,一个用于部署。

分段工作完美但在将代码提升到生产时会中断。这个文件似乎是个问题,但我不明白为什么 - 任何想法?



<div class="row invite-friends" data-page-id-invite-friend=''>
  <div class="col-lg-3">
    <%= render 'shared/user_info'%>
  </div>
  <div class="col-lg-6 well">
    <h3>Plans</h3>
    <p>Choose a plan to help you reach your goals. All plans deliver structured content from our team of experienced trainers to your feed every day.</p>
    <hr />
    


<div id="accordion" role="tablist" aria-multiselectable="true">
  
<% @diets.each do |diet| %> 

    <div class="panel panel-default">
    <div class="panel-heading" role="tab" id="heading<%=diet.id%>">
      <h4 class="panel-title">
        <a data-toggle="collapse" data-parent="#accordion" href="#collapse<%=diet.id%>" aria-expanded="true" aria-controls="collapse<%=diet.id%>">
          <%= diet.title%> <span class="caret"></span>
           </a>
      </h4>
          <div class="plans_meta"> 
            Rating: <%= content_with_emoji( "" * diet.rating.to_i) %>
            <br>
            Difficulty: <%= content_with_emoji("" * diet.difficulty.to_i) %>
            <br>
            Duration: <%= diet.duration %> days.
            <br>
            Trainer: <%= diet.user.name %>
            <br>
            Cost: <%= diet.cost %>$
            <br>
          </div> 
    </div>
    <div id="collapse<%=diet.id%>" class="panel-collapse collapse " role="tabpanel" aria-labelledby="heading<%=diet.id%>">
      <style>.embed-container { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; max-width: 100%; } .embed-container iframe, .embed-container object, .embed-container embed { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }</style><div class='embed-container'><iframe src='<%= diet.introvid%>' frameborder='0' webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></div>
         <div class="plans_subscribe"> 
          <button type="button" class="btn btn-success btn-block">Subscribe</button>
        </div>
    </div>
  </div>






<% end %>

</div>

  </div>
  <div class="col-lg-3">
    <%= render 'shared/links' %>
  </div>
</div>
&#13;
&#13;
&#13;

正如我所说,完全相同的代码在管道中的暂存应用程序中的heroku上运行,而不是在推送到生产时。我已经迁移了DB。

日志显示以下内容:

&#13;
&#13;
2016-08-05T19:34:45.767820+00:00 app[web.1]:     29:             <br>
2016-08-05T19:34:45.767817+00:00 app[web.1]: 
2016-08-05T19:34:45.767819+00:00 app[web.1]: ActionView::Template::Error (undefined method `name' for nil:NilClass):
2016-08-05T19:34:45.767822+00:00 app[web.1]:     32:             Cost: <%= diet.cost %>$
2016-08-05T19:34:45.767820+00:00 app[web.1]:     28:             Duration: <%= diet.duration %> days.
2016-08-05T19:34:45.767824+00:00 app[web.1]: 
2016-08-05T19:35:24.555153+00:00 heroku[router]: at=info method=GET path="/show_plans" host=www.myfitstat.com request_id=0e9ecc65-d9ba-4805-89af-802f804186e2 fwd="81.101.122.253" dyno=web.1 connect=0ms service=82ms status=500 bytes=1754
2016-08-05T19:35:24.436197+00:00 app[web.1]: Started GET "/show_plans" for 81.101.122.253 at 2016-08-05 20:35:24 +0100
2016-08-05T19:35:24.438213+00:00 app[web.1]: Processing by HomeController#show_plans as HTML
2016-08-05T19:35:24.440544+00:00 app[web.1]:   [1m[36mUser Load (1.4ms)[0m  [1mSELECT  "users".* FROM "users"  WHERE "users"."id" = 3  ORDER BY "users"."id" ASC LIMIT 1[0m
2016-08-05T19:35:24.443086+00:00 app[web.1]:   [1m[35mGroup Load (1.3ms)[0m  SELECT "groups".* FROM "groups" INNER JOIN "groups_users" ON "groups"."id" = "groups_users"."group_id" WHERE "groups_users"."user_id" = $1  [["user_id", 3]]
2016-08-05T19:35:24.444528+00:00 app[web.1]:   Rendered shared/_avatar.html.erb (0.5ms)
2016-08-05T19:35:24.446110+00:00 app[web.1]:   [1m[36mGroup Load (1.1ms)[0m  [1mSELECT  "groups".* FROM "groups"  WHERE "groups"."id" = $1 LIMIT 1[0m  [["id", 6]]
2016-08-05T19:35:24.447802+00:00 app[web.1]:   [1m[35m (1.0ms)[0m  SELECT COUNT(*) FROM "weights"  WHERE "weights"."user_id" = $1  [["user_id", 3]]
2016-08-05T19:35:24.448169+00:00 app[web.1]:   Rendered shared/_user_info.html.erb (4.4ms)
2016-08-05T19:35:24.449524+00:00 app[web.1]:   [1m[36mDiet Load (1.1ms)[0m  [1mSELECT "diets".* FROM "diets"[0m
2016-08-05T19:35:24.512148+00:00 app[web.1]:   Rendered home/show_plans.html.erb within layouts/application (68.4ms)
2016-08-05T19:35:24.513300+00:00 app[web.1]: ActionView::Template::Error (undefined method `name' for nil:NilClass):
2016-08-05T19:35:24.513301+00:00 app[web.1]:     27:             <br>
2016-08-05T19:35:24.513301+00:00 app[web.1]:     28:             Duration: <%= diet.duration %> days.
2016-08-05T19:35:24.513302+00:00 app[web.1]:     29:             <br>
2016-08-05T19:35:24.513302+00:00 app[web.1]:     30:             Trainer: <%= diet.user.name %>
2016-08-05T19:35:24.513303+00:00 app[web.1]:     31:             <br>
2016-08-05T19:35:24.513303+00:00 app[web.1]:     32:             Cost: <%= diet.cost %>$
2016-08-05T19:35:24.513304+00:00 app[web.1]:     33:             <br>
2016-08-05T19:35:24.513304+00:00 app[web.1]:   app/views/home/show_plans.html.erb:30:in `block in _app_views_home_show_plans_html_erb___2816138431848340693_69990420277100'
2016-08-05T19:35:29.391085+00:00 heroku[router]: at=info method=HEAD path="/" host=www.myfitstat.com request_id=4c0c4184-eea2-42a8-b6a0-500e85ccb9ec fwd="69.162.124.237" dyno=web.1 connect=1ms service=58ms status=200 bytes=778
2016-08-05T19:35:29.331354+00:00 app[web.1]: Started HEAD "/" for 69.162.124.237 at 2016-08-05 20:35:29 +0100
2016-08-05T19:35:31.244915+00:00 app[web.1]: Started HEAD "/users/sign_in" for 69.162.124.237 at 2016-08-05 20:35:31 +0100
2016-08-05T19:35:31.248854+00:00 app[web.1]: Processing by Devise::SessionsController#new as HTML
2016-08-05T19:35:31.595348+00:00 app[web.1]:   Rendered devise/shared/_links.html.erb (1.5ms)
2016-08-05T19:35:31.595414+00:00 app[web.1]:   Rendered devise/sessions/new.html.erb within layouts/application (342.3ms)
2016-08-05T19:35:31.609028+00:00 heroku[router]: at=info method=HEAD path="/users/sign_in" host=www.myfitstat.com request_id=dc1f95c4-50bd-422b-8070-8e196d612281 fwd="69.162.124.237" dyno=web.1 connect=1ms service=357ms status=200 bytes=778
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

您的数据在分段中与在生产中的不同之处似乎是一个问题。 diet.user在您的生产环境中为零,从错误消息中可以看出:

ActionView::Template::Error (undefined method `name' for nil:NilClass):
2016-08-05T19:35:24.513301+00:00 app[web.1]:     27:             <br>
2016-08-05T19:35:24.513301+00:00 app[web.1]:     28:             Duration: <%= diet.duration %> days.
2016-08-05T19:35:24.513302+00:00 app[web.1]:     29:             <br>
2016-08-05T19:35:24.513302+00:00 app[web.1]:     30:             Trainer: <%= diet.user.name %>
2016-08-05T19:35:24.513303+00:00 app[web.1]:     31:             <br>
2016-08-05T19:35:24.513303+00:00 app[web.1]:     32:             Cost: <%= diet.cost %>$
2016-08-05T19:35:24.513304+00:00 app[web.1]:     33:             <br>

我会进入数据库并验证diet.user是否有值。