Rails抛出错误:ActionView :: Template :: Error(在文章中找不到名为' report_type'的关联;也许你拼错了它

时间:2017-11-29 10:57:00

标签: ruby-on-rails ruby-on-rails-4

    `ActionView::Template::Error (Association named 'report_type' was not found on Article; perhaps you misspelled it?):
        37:             <div class="col-md-12 text-center">
        38:               <div class="reportPage carousel-caption">
        39:               <p class="para-heading bg-circular color-white">
        40:                 <%unless @reports.present? %>
        41:                   <%= 'Statistical' %>
        42:                     <%else%>
        43:                       <%= 'Syndicate' %>



     app/views/reports/index.html.erb:40:in `_app_views_reports_index_html_erb___75771321459162625_96601780'
  app/controllers/reports_controller.rb:12:in `index'

我在生产中遇到此错误,在具有相同数据的本地实例上也是我没有收到此错误。尝试了很多事情,没有弄错。

Article.rb

class Article < ActiveRecord::Base
       extend FriendlyId
       friendly_id :slug_candidates, use: :slugged
       mount_uploader :article_image, ArticleImageUploader
       belongs_to :author

ReportType.rb

class ReportType < ActiveRecord::Base
  mount_uploader :report_type_image, ReportTypeImageUploader
  has_many :reports
  has_many :statistical_reports
  extend FriendlyId
  friendly_id :name, use: :slugged

请提供任何帮助或建议。

0 个答案:

没有答案