嗨,在重新索引数据时,我在Categorization.rb文件中为nil:NilClass获取了NoMethodError: undefined method `full_name‘。
代码在rails中
Categorization.rb
class Categorization < ActiveRecord::Base
searchable auto_index: false do
text :title, stored: true, boost: Knome::Constants::Boost::NAME
text :description, stored: true, boost: Knome::Constants::Boost::DESCRIPTION
text :user do
user.full_name
end
integer :co_owner_ids, multiple: true do
added_co_owners
end
integer :status do
nil
end
time :created_at
time :updated_at
end
end
User.rb
def full_name
"#{first_name} #{last_name}"
end我已经迁移了数据,但仍然收到相同的错误。所以请帮帮我。
谢谢你
发布于 2015-05-20 15:03:24
这是因为您在定义方法full_name之前调用了它。
早点定义它,然后向下移动调用它的代码。
https://stackoverflow.com/questions/30341707
复制相似问题