未初始化的常量错误,只在heroku上 [英] uninitialized constant error, only on heroku

查看:92
本文介绍了未初始化的常量错误,只在heroku上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  ActionView :: Template:我的本地服务器上的一切都很好,但是当我在heroku上部署时, :Error(未初始化的常量Report :: View):

我不确定发生了什么。有任何想法吗?我在迁移过程中遇到了一些麻烦,所以我做了并修正了它,并将其迁移并推回。然后 heroku restart



整个日志:

  app [web.1]:开始GET/ reportsfor 76.28.58.42于2012-02-20 18:55:19 -0800 
app [web.1] :
app [web.1]:
app [web.1]:通过ReportsController处理#index为HTML
app [web.1]:24:<如果current_user.access > = 3%>
app [web.1]:29:< img src =<%= image_path('newcomment.png')%> ID = 指示器 >
app [web.1]:app / models / report。 `indicator'
app [web.1]:
heroku [router]:GET dyno = web.1 queue = 0 wait = 0ms service = 39ms status = 500 bytes = 728
app [ web.1]:ActionView :: Template :: Error(未初始化的常量Report :: View):
app [web.1]:app / views / reports / index.html。 `_app_views_reports_index_html_erb__2344284806505066880_37258240__573144668886847782'
app [web.1]:
app [web.1]:
app [web.1]:23:<%end%>
app [web.1]:26:<%if report.indicator(current_user)== 1%>
app [web.1]:27:< img src =<%= image_path('newreportwithcomment.png')%> ID = 指示器 >
app [web.1]:渲染布局/应用程序中的reports / index.html.erb(29.3ms)
app [web.1]:28:<%elsif report.indicator(current_user) == 2%>
app [web.1]:25:< td>
app [web.1]:app / views / reports / index.html。 `block in _app_views_reports_index_html_erb__2344284806505066880_37258240__573144668886847782'
app [web.1]:app / controllers / reports_controller。 `index'
heroku [nginx]:76.28.58.42 - - [21 / Feb / 2012:02:55:19 +0000]GET / reports HTTP / 1.1500 728Mozilla / 5.0 ; Intel Mac OS X 10_7_3)AppleWebKit / 535.11(KHTML,如Gecko)Chrome / 17.0.963.56 Safari / 535.11repair.heroku.com
app [web.1]:在33ms内完成500次内部服务器错误

报表控制器:

  def index 
if current_user.access> = 2
= Report.search(params [:search])。paginate(:page => params [:page],:per_page = > 25).order('created_at DESC')
else
= Report.where(created_at>?,30.days.ago).paginate(:page => params [:页面],:per_page => 25).order('created_at DESC')
end

respond_to do | format |
format.html#index.html.erb
format.xml {render:xml => }
end
end

reports / views / index(从第18行开始)

 <%.each do | report | %GT; 
<%if current_user.access> = 2%>
< tr class =<%=循环('奇数行','偶数行')%> onClick =location.href ='reports /<%= report.id%>'style =>
<%else%>
< tr class =<%= cycle('odd-line','even-line')%>>
<%end%>
<%if current_user.access> = 3%>
< td>
<%if report.indicator(current_user)== 1%>
< img src =<%= image_path('newreportwithcomment.png')%> ID = 指示器 >
<%elsif report.indicator(current_user)== 2%>
< img src =<%= image_path('newcomment.png')%> ID = 指示器 >
<%elsif report.indicator(current_user)== 3%>
< img src =<%= image_path('newreport.png')%> ID = 指示器 >
<%end%>
< / td>
<%end%>

report.rb(从第24行开始)

  def指示符(current_user)
如果self.views.where('user_id =?',current_user.id).first!= nil
= self。 views.where('user_id =?',current_user.id).first
如果self.comments.first!= nil
如果self.comments.last.created_at> .updated_at
return 2
else
return 0
end
else
return 0
end
elsif self.comments.first !=无
返回1
其他
返回3
结束
结束

view.rb

  class View< ActiveRecord :: Base 
belongs_to:user
belongs_to:report
end


解决方案

我需要了解更多关于git的信息。 我回去做了 git add。然后提交并推送,一切正常。


Everything is working great on my local server, but when I deploy on heroku I get:

 ActionView::Template::Error (uninitialized constant Report::View):

I'm not sure what's going on. Any ideas? I had some trouble with my migrations so I did and , fixed it, migrated it, and pushed it back up. then heroku restart.

the entire log:

app[web.1]: Started GET "/reports" for 76.28.58.42 at 2012-02-20 18:55:19 -0800
app[web.1]: 
app[web.1]: 
app[web.1]:   Processing by ReportsController#index as HTML
app[web.1]:     24:     <% if current_user.access >= 3 %>
app[web.1]:     29:                 <img src="<%= image_path('newcomment.png') %>" id="indicator">
app[web.1]:   app/models/report. `indicator'
app[web.1]: 
heroku[router]: GET  dyno=web.1 queue=0 wait=0ms service=39ms status=500 bytes=728
app[web.1]: ActionView::Template::Error (uninitialized constant Report::View):
app[web.1]:   app/views/reports/index.html. `_app_views_reports_index_html_erb__2344284806505066880_37258240__573144668886847782'
app[web.1]: 
app[web.1]: 
app[web.1]:     23:     <% end %>
app[web.1]:     26:             <% if report.indicator(current_user) == 1 %>
app[web.1]:     27:                 <img src="<%=  image_path('newreportwithcomment.png') %>" id="indicator">
app[web.1]: Rendered reports/index.html.erb within layouts/application (29.3ms)
app[web.1]:     28:             <% elsif report.indicator(current_user) == 2 %>
app[web.1]:     25:         <td>
app[web.1]:   app/views/reports/index.html. `block in _app_views_reports_index_html_erb__2344284806505066880_37258240__573144668886847782'
app[web.1]:   app/controllers/reports_controller. `index'
heroku[nginx]: 76.28.58.42 - - [21/Feb/2012:02:55:19 +0000] "GET /reports HTTP/1.1" 500 728 "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11" repair.heroku.com
app[web.1]: Completed 500 Internal Server Error in 33ms

reports controller:

  def index
    if current_user.access >= 2
       = Report.search(params[:search]).paginate(:page => params[:page], :per_page => 25).order('created_at DESC')
    else
       = Report.where("created_at > ?", 30.days.ago).paginate(:page => params[:page], :per_page => 25).order('created_at DESC')
    end

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml =>  }
    end
  end

reports/views/index (starting at line 18)

<% .each do |report| %>
    <% if current_user.access >= 2 %>
      <tr class="<%= cycle('odd-line', 'even-line') %>" onClick="location.href='reports/<%= report.id  %>'" style="">
    <% else %>
      <tr class="<%= cycle('odd-line', 'even-line') %>">
    <% end %>
    <% if current_user.access >= 3 %>
        <td>
            <% if report.indicator(current_user) == 1 %>
                <img src="<%= image_path('newreportwithcomment.png') %>" id="indicator">
            <% elsif report.indicator(current_user) == 2 %>
                <img src="<%= image_path('newcomment.png') %>" id="indicator">
            <% elsif report.indicator(current_user) == 3 %>
                <img src="<%= image_path('newreport.png') %>" id="indicator">
            <% end %>
        </td>
    <% end %>

report.rb (starts on line 24)

  def indicator(current_user)
    if self.views.where('user_id = ?', current_user.id).first != nil
       = self.views.where('user_id = ?', current_user.id).first
      if self.comments.first != nil
        if self.comments.last.created_at > .updated_at
          return 2
        else
          return 0
        end
      else
        return 0
      end
    elsif self.comments.first !=nil
      return 1
    else
      return 3
    end
  end

view.rb

class View < ActiveRecord::Base
  belongs_to :user
  belongs_to :report
end

解决方案

I need to learn more about git.

I went back and did git add . then committed and pushed and everything worked fine.

这篇关于未初始化的常量错误,只在heroku上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆