在Rails中我得到错误'实例变量@cached_changed_attributes未定义'在尝试为记录添加编辑链接时

时间:2015-06-22 09:46:28

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

我只是想在这样的产品列表中添加product记录的编辑链接:

<td class='textcenter'><%= link_to 'Edit', edit_dash_product_path(product), class: 'label label-warning' %></td>

在这里我得到这样的错误:

instance variable @cached_changed_attributes not defined

我没有这样的实例变量,甚至没有为应用添加缓存。可能是什么问题?

完整堆栈跟踪,模板文件:https://gist.github.com/THPubs/7aae392ea3a2464c8638

产品型号:

# == Schema Information
#
# Table name: products
#
#  id             :integer          not null, primary key
#  code           :string
#  name           :string
#  description    :text
#  price          :money
#  category_id    :integer
#  subcategory_id :integer
#  qty            :integer
#  sold           :integer          default("0")
#  vendor_id      :integer
#  brand_id       :integer
#  helpfultips    :text
#  discount       :integer
#  discountend    :datetime
#  discountterms  :text
#  material       :string
#  arrangedby     :string
#  published      :date
#  model          :string
#  weight         :integer
#  weightunit     :string
#  warranty       :string
#  features       :text
#  specs          :text
#  ingredients    :text
#  included       :text
#  return         :text
#  approved       :boolean          default("false")
#  slug           :string
#  featuredimg    :integer          default("0")
#  created_at     :datetime         not null
#  updated_at     :datetime         not null
#

1 个答案:

答案 0 :(得分:1)

好的我修好了!正如@Simone在评论中指出的那样,问题在于friendly_id。这是在更新我的宝石后发生的。 friendly_id有新宝石的问题(最有可能是主动记录)。

解决方案

要解决此问题,我必须将friendly_id升级到最新的测试版,方法是将其添加到Gemfile:

gem 'friendly_id', '~> 5.2.0.beta.1'

不是最好的修复,但现在可以使用。