Tag: searchlogic

Searchlogic OR条件导致未定义的方法

我确信我忽略了一些东西,因为这是我第一次使用Searchlogic。 每当我在控制器中使用类似于Listing.city_like_or_state_like(params[:search])的语句时,Rails都会返回“未定义方法”错误。 我正在尝试搜索同一模型中的2个字段。 但是,如果我使用Listing.city_like(params[:search])一切都很好。 我在这里错过了什么吗? 我认为OR条件可以与Searchlogic链接在一起。 如何实现OR语句?

重用named_scope来定义另一个named_scope

我看到问题的本质 有一天,如果我没弄错的话,我已经看到了重用named_scope来定义另一个named_scope的例子。 像这样的东西(不记得确切的语法,但这正是我的问题): named_scope :billable, :conditions => … named_scope :billable_by_tom, :conditions => { :billable => true, :user => User.find_by_name(‘Tom’) } 问题是:如果可能的话,确切的语法是什么? 我找不到它,谷歌也没有帮助。 一些解释 为什么我真的想要它,是因为我使用Searchlogic来定义一个复杂的搜索,这可能会产生如下表达式: Card.user_group_managers_salary_greater_than(100) 但到处都是太久了。 因为据我所知,Searchlogic只是动态定义了named_scopes,我想在Card类上设置一个named_scope,如下所示: named_scope from_big_guys, { user_group_managers_salary_greater_than(100) } – 这是我在named_scope中使用那个漫长的Searchlogic方法的地方。 但是,再一次,语法是什么? 想不出来。 恢复 那么,named_scope嵌套(我不是指链接)实际上可能吗?

使用搜索逻辑的日期条件

Rails插件 – 来自二进制逻辑的Searchlogic – 提供按日期过滤的function。 我的表单设置如此…… 但是,我从控制器中生成的@search对象返回的日期… @search = Task.with_member(current_user).search(params[:search]) 生成一个看起来像这样的日期参数 {:due_at_after=>Sat, 31 Oct 2009 20:00:00 EDT -04:00} 使用这两种格式,表单不会显示所选的下拉列表。 看起来searchlogic对象中的格式也使用了时区调整时间。 有关如何处理这个的任何想法?

searchlogic和虚拟属性

假设我有以下型号: Person <AR def name [self.first_name,self.middle_name,self.last_name].select{|n| n.present?}.join(' ') end end 如何使用searchlogic搜索虚拟属性,例如: Person.search.name_like ‘foo’ 我可以构建一个大的声明,如: Person.search.first_name_like_or_last_name_like_or_… ‘argh’ 但肯定有一种更优雅的方式。

使用Rails进行全文搜索

我一直在研究为Rails搜索插件/gem。 大多数文章将Ferret(Lucene)与Ultrasphinx或者可能是Thinking Sphinx进行了比较,但没有人谈论SearchLogic 。 有没有人有任何关于这个比较的线索? 你用了什么,它的表现如何?

将两个命名范围与OR(而不是AND)组合在一起

我想找到所有Annotations其主体是: 等于 ”?” 要么 喜欢 ”[?]” 最好的方法是什么? 我想尽可能使用SearchLogic ,但是SearchLogic允许您执行以下各项操作: Annotation.body_equals(‘?’) Annotation.body_like(‘[?]’) 并且你总是可以将它们链接在一起: Annotation.body_equals(‘?’).body_like(‘[?]’) 我不确定如何将它们与OR结合起来。 请注意,如果命名范围相同, 则可以将命名范围与OR组合使用。 我可以这样做: Annotation.body_equals_or_body_like(‘?’) 但这没有用。 请注意,我并不依赖于SearchLogic,但对于不需要破坏其抽象的解决方案来说,它会很棒。

Rails:堆栈级别太深的错误

我的rails应用程序有3个型号。 小道,地区和特色。 我可以在lib / tasks目录中很好地与这些模型进行交互。 我用anemone来抓取并填充数据库。 我在模型上调用的示例: Trail.find_or_initialize_by_title(detail_title) 我现在正在尝试编写一个使用该模型的控制器。 class TrailController Trail.all end end 现在,如果我打开rails控制台并尝试app.get(‘trail/index’)我得到一个500返回代码,我在我的development.log看到以下内容 SystemStackError(堆栈级别太深): app / controllers / trail_controller.rb:23:在’index’中 所以我显然会引起一些无限的递归。 第23行对应于索引方法的主体。 我在我的应用程序中尝试了其他模型:function和区域,结果是一样的。 有人能告诉我这里我做错了什么,或者我怎么能得到更多的追踪来找出究竟是无限递归的? 我的模型非常简单: class Feature true end class Region true end class Trail true end 看来这是由searchlogic gem引起的。 我在我的Gemfile中有这个: gem ‘rd_searchlogic’, :require => ‘searchlogic’, :git => ‘git://github.com/railsdog/searchlogic.|~ 当我注释掉那一行时,运行bundle install并重试app.get工作正常。 所以searchlogic以某种方式干扰了Trail.all。 为什么Trail.all不能安装searchlogic?

如何让searchlogic与rails 3一起使用?

我把searchlogic放在我的gemfile中…现在我的rails服务器将无法启动:( 这是错误消息 gems/ruby-1.8.7-p299/gems/activesupport-3.0.0/lib/active_support/core_ext/module/aliasing.rb:31:in `alias_method’: undefined method `merge_joins’ for class `Class’ (NameError) from /Users/omiohoro/.rvm/gems/ruby-1.8.7-p299/gems/activesupport-3.0.0/lib/active_support/core_ext/module/aliasing.rb:31:in `alias_method_chain’ from /Users/omiohoro/.rvm/gems/ruby-1.8.7-p299/gems/searchlogic-2.4.27/lib/searchlogic/active_record/consistency.rb:8:in `included’ from /Users/omiohoro/.rvm/gems/ruby-1.8.7-p299/gems/searchlogic-2.4.27/lib/searchlogic/active_record/consistency.rb:7:in `class_eval’ from /Users/omiohoro/.rvm/gems/ruby-1.8.7-p299/gems/searchlogic-2.4.27/lib/searchlogic/active_record/consistency.rb:7:in `included’ from /Users/omiohoro/.rvm/gems/ruby-1.8.7-p299/gems/searchlogic-2.4.27/lib/searchlogic.rb:34:in `include’ from /Users/omiohoro/.rvm/gems/ruby-1.8.7-p299/gems/searchlogic-2.4.27/lib/searchlogic.rb:34 from /Users/omiohoro/.rvm/gems/ruby-1.8.7-p299/gems/bundler-1.0.0/lib/bundler/runtime.rb:64:in `require’ from /Users/omiohoro/.rvm/gems/ruby-1.8.7-p299/gems/bundler-1.0.0/lib/bundler/runtime.rb:64:in `require’ from /Users/omiohoro/.rvm/gems/ruby-1.8.7-p299/gems/bundler-1.0.0/lib/bundler/runtime.rb:62:in `each’ from /Users/omiohoro/.rvm/gems/ruby-1.8.7-p299/gems/bundler-1.0.0/lib/bundler/runtime.rb:62:in `require’ from /Users/omiohoro/.rvm/gems/ruby-1.8.7-p299/gems/bundler-1.0.0/lib/bundler/runtime.rb:51:in `each’ from /Users/omiohoro/.rvm/gems/ruby-1.8.7-p299/gems/bundler-1.0.0/lib/bundler/runtime.rb:51:in `require’ from /Users/omiohoro/.rvm/gems/ruby-1.8.7-p299/gems/bundler-1.0.0/lib/bundler.rb:112:in `require’ from /Users/omiohoro/glowing-rain-75/config/application.rb:7 from /Users/omiohoro/.rvm/gems/ruby-1.8.7-p299/gems/railties-3.0.0/lib/rails/commands.rb:28:in `require’ from […]