Rails 5中的参数数量错误(给定2,预期为1)

问题描述 投票:1回答:1

我正在将项目从Rails 3项目升级到Rails 5.今天我遇到了一个奇怪的错误。

现在项目正在Rails 5上运行。在项目中有模型UserArticle。当我查询User模型时,一切都很好:

User.all # returns all records 
User.first # returns first record

但是当我查询Article模型时,每个查询都会出现相同的错误:

Article.all # ArgumentError: wrong number of arguments (given 2, expected 1)
Atricle.first # ArgumentError: wrong number of arguments (given 2, expected 1)

该项目使用devise宝石,User模型是由这个宝石创建的,但Article模型不是。

问题是我如何调查这类问题?我应该使用什么方法来找到错误的来源?

附:

class Article < ApplicationRecord
  extend FriendlyId

  belongs_to :user

  attr_accessor :active, :description, :meta_d, :meta_k, :photo, :short_desc, :title, :photo_cache, :article_category_id, :tag_list, :tag_ids
  attr_accessor :main_slider, :main_photo, :main_photo_cache

  friendly_id :title, use: :slugged

  acts_as_taggable

  def normalize_friendly_id(text)
    text.to_slug.normalize(transliterations: :russian).to_s
  end

  belongs_to :article_category
end
ruby-on-rails-3 ruby-on-rails-5 activemodel
1个回答
0
投票

问题是FriendlyId宝石,我不得不升级到5.2.0版本

© www.soinside.com 2019 - 2024. All rights reserved.