简体   繁体   中英

uninitialized constant error, only on heroku

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM