gpt4 book ai didi

ruby-on-rails - 思考狮身人面像无法配置开发配置

转载 作者:行者123 更新时间:2023-12-02 04:55:12 26 4
gpt4 key购买 nike

我已经安装了 thinking sphinx 并且在运行 rake ts:index 之后,它无法配置开发文件。文件已创建,但它是空的。

Generating configuration to /Users/lexi87/dating/config/development.sphinx.conf
rake aborted!
undefined method `type' for nil:NilClass
/Users/lexi87/.rvm/gems/ruby-2.0.0-p0/gems/thinking-sphinx-3.0.0/lib/thinking_sphinx/active_record/attribute/type.rb:64:in `type_from_database'
/Users/lexi87/.rvm/gems/ruby-2.0.0-p0/gems/thinking-sphinx-3.0.0/lib/thinking_sphinx/active_record/attribute/type.rb:17:in `type'
/Users/lexi87/.rvm/gems/ruby-2.0.0-p0/gems/thinking-sphinx-3.0.0/lib/thinking_sphinx/active_record/attribute.rb:4:in `type'
/Users/lexi87/.rvm/gems/ruby-2.0.0-p0/gems/thinking-sphinx-3.0.0/lib/thinking_sphinx/active_record/attribute/sphinx_presenter.rb:30:in `sphinx_type'
/Users/lexi87/.rvm/gems/ruby-2.0.0-p0/gems/thinking-sphinx-3.0.0/lib/thinking_sphinx/active_record/attribute/sphinx_presenter.rb:18:in `collection_type'
/Users/lexi87/.rvm/gems/ruby-2.0.0-p0/gems/thinking-sphinx-3.0.0/lib/thinking_sphinx/active_record/sql_source.rb:107:in `block in prepare_for_render'
/Users/lexi87/.rvm/gems/ruby-2.0.0-p0/gems/thinking-sphinx-3.0.0/lib/thinking_sphinx/active_record/sql_source.rb:104:in `each'
/Users/lexi87/.rvm/gems/ruby-2.0.0-p0/gems/thinking-sphinx-3.0.0/lib/thinking_sphinx/active_record/sql_source.rb:104:in `prepare_for_render'
/Users/lexi87/.rvm/gems/ruby-2.0.0-p0/gems/thinking-sphinx-3.0.0/lib/thinking_sphinx/active_record/sql_source.rb:61:in `render'
/Users/lexi87/.rvm/gems/ruby-2.0.0-p0/gems/riddle-1.5.6/lib/riddle/configuration/index.rb:29:in `block in render'
/Users/lexi87/.rvm/gems/ruby-2.0.0-p0/gems/riddle-1.5.6/lib/riddle/configuration/index.rb:29:in `collect'
/Users/lexi87/.rvm/gems/ruby-2.0.0-p0/gems/riddle-1.5.6/lib/riddle/configuration/index.rb:29:in `render'
/Users/lexi87/.rvm/gems/ruby-2.0.0-p0/gems/thinking-sphinx-3.0.0/lib/thinking_sphinx/core/index.rb:48:in `render'
/Users/lexi87/.rvm/gems/ruby-2.0.0-p0/gems/riddle-1.5.6/lib/riddle/configuration.rb:39:in `block in render'
/Users/lexi87/.rvm/gems/ruby-2.0.0-p0/gems/riddle-1.5.6/lib/riddle/configuration.rb:39:in `collect'
/Users/lexi87/.rvm/gems/ruby-2.0.0-p0/gems/riddle-1.5.6/lib/riddle/configuration.rb:39:in `render'
/Users/lexi87/.rvm/gems/ruby-2.0.0-p0/gems/thinking-sphinx-3.0.0/lib/thinking_sphinx/configuration.rb:81:in `render'
/Users/lexi87/.rvm/gems/ruby-2.0.0-p0/gems/thinking-sphinx-3.0.0/lib/thinking_sphinx/configuration.rb:87:in `block in render_to_file'
/Users/lexi87/.rvm/gems/ruby-2.0.0-p0/gems/thinking-sphinx-3.0.0/lib/thinking_sphinx/configuration.rb:87:in `render_to_file'
/Users/lexi87/.rvm/gems/ruby-2.0.0-p0/gems/thinking-sphinx-3.0.0/lib/thinking_sphinx/rake_interface.rb:4:in `configure'
/Users/lexi87/.rvm/gems/ruby-2.0.0-p0/gems/thinking-sphinx-3.0.0/lib/thinking_sphinx/rake_interface.rb:31:in `index'
/Users/lexi87/.rvm/gems/ruby-2.0.0-p0/gems/thinking-sphinx-3.0.0/lib/thinking_sphinx/tasks.rb:9:in `block (2 levels) in <top (required)>'
/Users/lexi87/.rvm/gems/ruby-2.0.0-p0/bin/ruby_noexec_wrapper:14:in `eval'
/Users/lexi87/.rvm/gems/ruby-2.0.0-p0/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => ts:index

我不确定这是否与我在 indices 文件夹下的 user_index.rb 有关。

ThinkingSphinx::Index.define :user, :with => :active_record do
# fields
indexes content
indexes user.name, :as => :user, :sortable => true

# attributes
has user_id, created_at, updated_at, ethnicity, religion

end

这是我的 thinking_sphinx.yml 文件:

development:
mysql41: 9312
test:
mysql41: 9313
production:
mysql41: 9312

如有任何帮助,我们将不胜感激。

最佳答案

这个错误,虽然不清楚,是由于你的属性引用之一不太正确......如果你正在索引 User 模型,那么我猜它没有一个名为 user - 所以,user_id 应该只是 id,而 user.name 应该只是 name:

ThinkingSphinx::Index.define :user, :with => :active_record do
# fields
indexes content
indexes name, :as => :user, :sortable => true

# attributes
has id, created_at, updated_at, ethnicity, religion
end

关于ruby-on-rails - 思考狮身人面像无法配置开发配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18112095/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com