首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NoMethodError:重建数据索引时nil:NilClass的未定义方法`full_name

NoMethodError:重建数据索引时nil:NilClass的未定义方法`full_name
EN

Stack Overflow用户
提问于 2015-05-20 14:18:49
回答 1查看 397关注 0票数 0

嗨,在重新索引数据时,我在Categorization.rb文件中为nil:NilClass获取了NoMethodError: undefined method `full_name‘。

代码在rails中

Categorization.rb

代码语言:javascript
复制
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

我已经迁移了数据,但仍然收到相同的错误。所以请帮帮我。

谢谢你

EN

回答 1

Stack Overflow用户

发布于 2015-05-20 15:03:24

这是因为您在定义方法full_name之前调用了它。

早点定义它,然后向下移动调用它的代码。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30341707

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档