Every repository with this icon (
Every repository with this icon (
| Description: | Searchlogic makes using ActiveRecord named scopes easier and less repetitive. edit |
-
Association chains that mention the same table twice produce incorrect results
1 comment Created 3 months ago by GFunk911For the example, take the following schema:
Product: id
ProductCategory: id, product_id, category_id
Category: idRows: You have one product in multiple categories
Product id: 1ProductCategory id: 1, category_id: 1, product_id: 1
ProductCategory id: 2, category_id: 2, product_id: 1Category id: 1
Category id: 2Say you want to find all categories that contain a product which is also in category X.
The following scope returns 2 copies of category 1, since the where sql references the wrong product_categories table. It should return categories 1 and 2
Category.product_categories_product_product_categories_category_id_equals(1)
SELECT
categories.* FROMcategories
INNER JOINproduct_categoriesON product_categories.category_id = categories.id
INNER JOINproductsONproducts.id =product_categories.product_id
INNER JOINproduct_categoriesproduct_categories_products ON product_categories_products.product_id = products.id
WHERE (product_categories.category_id = 235)
Comments
-
7 comments Created 3 months ago by binarylogic@Ben Johnsonxfrom-lighthousexAttribute with multiple parameters|S| newxHello, here is a feature request
Using named scope like "created_at_after" with helper like "form.date_select" which produces created_at(1i), created_at(2i) ... are not handled.
@@@ html <% form_for(@foos) do |f| %>
<p> <%= f.label :bar_at, ’Bar at after’ %> <%= f.date_select :bar_at_after %> </p> <p> <%#= f.label :bar_at, ’Bar at after’ %> <%#= f.text_field :bar_at %> </p> <p> <%= f.label :bar %> <%= f.text_field :bar_equals %> </p> <p> <%= f.submit :search %> </p>@@@
It ends in an obvious attribute(xi) not recognized. I can still used a text_field helper and pass a string as shown in the example, but that’s not always what can be expected in a search form.
It would be nice feature to have.
JH. Chabran
This ticket has 0 attachment(s).
Comments
binarylogic
Sun Aug 09 01:51:30 -0700 2009
| link
I agree, I tend to always use a javascript calendar date select, etc. So I have never had this issues. I don't think this would be too difficult to solve.
I added support for Date, as you can see there : http://github.com/jhchabran/searchlogic/blob/2d3d7ac5d7a267c8a367bf0066683a9212efc1de/lib/searchlogic/search.rb
It lacks support Time class and maybe some cosmetic changes, but it basically works. ( an expectation was added to search_spec too ).
binarylogic
Sun Aug 09 20:54:50 -0700 2009
| link
Thanks for doing this. I tried refactoring the code and couldn't really follow it. I can't safely pull that code in because I don't completely understand it and it was really hard to follow.
binarylogic
Sun Aug 09 20:56:28 -0700 2009
| link
Also, that code would be best in a completely separate module instead of changing the class itself.
Separating it in a module is basically doable, but it will leads to hook Search#conditions=, Search#method_missing, which seems to me to be a lot of work for just one line and maybe a bit unreliable if you modify these later.
This feature is clearly not critical, but it feels to me that not supporting all form helpers makes it at just a small step from being completely transparent for developers using it.
You wrote you found it hard to follow, can you detail a bit more ?
Rails multi-parameters are weird and in my opinion should be handled earlier, so params[:created_at] should return a date object or at least one string when submitted with three parameters, which would solve everything in the current case.
This forces me to rewrite handling code for theses parameters because as they did in AR it's coupled with models, and leads to a tricky regexp ( created_at(3i) means third argument with need to be casted as an integer), it's easy to write clear code for that, but in the original AR multi-parameter stuff, they allowed support for things like attribute(4f) and I kept support for these to stay coherent.
It was that part you found confusing or something else ?
And btw while I'm here thanks for SearchLogic, I saved much time using it :-)
binarylogic
Tue Aug 18 22:40:17 -0700 2009
| link
I agree, the rails multi parameters are weird and complicated, which is why I try to avoid them. I don't know that your code was hard to follow, its the problem at hand that is hard. My BIG thing with v2 is to keep it simple, and if I add in a feature it needs to be separate out into its own module. v1 got bloated and very hard to maintain. I want to keep v2 simple. Simplicity is better for everyone. Less problems, better performance, etc.
So if you could split this out into a multi parameter module I would add that in. I added your code it and it started to get complicated and harder for me to maintain, which is why I removed it.
Thanks.
We needed this for a client project earlier today so I spent some time writing an alternative implementation. It hooks in a bit differently (alias_method_chain with conditions=) but it works well for the stuff I've tested.
It's a bit more complex than jhchabran's approach as well (although, it was
inspired / designed like it in some parts) and it's built around AR's implementation
/ how the AR implementation is coded as of Rails 2.3.You can see the patch changes at http://github.com/Sutto/searchlogic/, with the actual implementation itself at http://github.com/Sutto/searchlogic/blob/master/lib/searchlogic/search_ext/multiparameter_assignment.rb
-
4 comments Created 3 months ago by binarylogic@Ben Johnsonxconditionsxfrom-lighthousexgroupxgroupingxnot_group support|S| openxhey,
is something like a ’not_group’ available within searchlogic (or in combination with ActiveRecord)?
e.g.:
s=System.new_search
=> #25}>g=s.conditions.not_group => # g.name_equals="test" => "test" g.descr_equals="test" => "test" s.count => 95
generated sql:
SQL (0.5ms) SELECT count("systems".id) AS count_id FROM "systems" WHERE (NOT (("systems"."name" = ’test’ AND "systems"."descr" = ’test’)))This ticket has 0 attachment(s).
Comments
binarylogic
Fri Aug 07 15:24:37 -0700 2009
| link
not_group support
After digging around, trying to find another solution without success I decided to implement that feature within searchlogic. The changes are committed to a fork of searchlogic (http://github.com/sdecastelberg/searchlogic/tree/master). Maybe someone can have a look at it. Feedback is appreciated. (i’m rather new to ruby/ror..)
The implemented not_group works fine for my needs.
by sdecastelberg
binarylogic
Fri Aug 07 15:24:42 -0700 2009
| link
not_group support
Why wouldn’t you adjust your conditions to have the opposite effect instead of doing a not_group. Either way, whatever works for you, if you like the not_group solution then I think its fine, but couldn’t you accomplish the same thing by adjusting your conditions?
by Ben Johnson
binarylogic
Fri Aug 07 15:24:45 -0700 2009
| link
not_group support
the not_group was initially needed for a monitoring/inventory application to map network components (software and hardware) and provide configuration for different network and application layer scanners.
For bulk editing, reporting, etc. we needed an exact match search for every single attribute on every model.
Search Dialog
*group1
*SnmpScan (include) *oid=ssCpuIdle *alarm-threshold=90 *System (exclude) *Status=Test *Modified Date start: 2009-01-01would match the following search (when searching for systems)
(system.snmp_scan.oid=ssCpuIdle AND system.snmp_scan.alarm_threshold=90) AND NOT (system.state=Test AND modified_date>=2009-01-01)The attributes are grouped model-wise and can be combined differently (and, or) and the search can be expanded by adding other groups with subgroups.
The include/exclude flag just sets the not_group attribute on the group, without having to negate all the single attributes.by sdecastelberg
binarylogic
Fri Aug 07 15:24:47 -0700 2009
| link
not_group support
I see what you’re saying. But searchlogic deals with single conditions. If you are writing your own named scope for these conditions why not add in the "NOT" yourself? I guess I’m a little confused how you are using searchlogic and how you want to use it.
by Ben Johnson
-
3 comments Created 3 months ago by binarylogic@Ben Johnsonxassociationsxfrom-lighthousexorderxsearchx#search ignores :order argument on associations which have an order defined|S| openxConsider a class Foo, with associated Bars:
@@@ ruby class Foo < ActiveRecord::Base
has_many :bars, :order => :name end
@@@If you do:
@@@ ruby Foo.bars.search(:order => "ascend_by_size").all
@@@The results are still sorted by :name -- i.e. the "ascend_by_size" :order argument to the #search method is ignored.
The SQL query looks like:
@@@ sql SELECT * FROM bars WHERE bars.foo_id = 1 ORDER BY bars.name;
@@@--
Is this a bug?
This ticket has 0 attachment(s).
Comments
binarylogic
Fri Aug 07 15:25:14 -0700 2009
| link
#search ignores :order argument on associations which have an order defined
Hmm, I’m not sure, let me add a failing test and play around with it. If you want fork the project and write a quick failing test. It looks like the Searchlogic::Search#current_scope is taking priority.
by Ben Johnson
Here is a failing spec: It's running through a defined named_scope, same issue though:
it "should overwrite ordering through a named_scope" do %w(bjohnson thunt).each { |username| User.create(:username => username) } User.class_eval { named_scope :by_username, :order => "username DESC" } User.by_username.ascend_by_username.should == User.all(:order => "username ASC") endHmm, looks like this is the same problem as http://github.com/binarylogic/searchlogic/issues#issue/17 which is an AR problem, not a searchlogic one
-
5 comments Created 3 months ago by binarylogic@Ben Johnsonxfrom-lighthousexorderxorder_byxMulti column ordering|S| openxI would like to have ordering by multiple columns, where each of them can be ascending and descending. Example: "ORDER BY date ASC, id DESC"
What about creating scope like this:
order_by_date_asc_and_id_descSadly, nesting orders with scopes is not possible in Rails 2.3.2, see here:
https://rails.lighthouseapp.com/projects/8994/tickets/2253-named_scope-and-nested-order-clausesSo it should be created as ONE scope.
This ticket has 0 attachment(s).
Comments
binarylogic
Fri Aug 07 15:26:14 -0700 2009
| link
Multi column ordering
Yeah, that would be a nice feature and it’s probably something AR scopes should handle anyways. It looks like it will get applied though, I think they are just waiting on better tests.
by Ben Johnson
binarylogic
Fri Aug 07 15:26:16 -0700 2009
| link
Multi column ordering
Actually my tests are showing that AR does support multi column ordering by chaining named scopes. Are you not seeing that?
by Ben Johnson
binarylogic
Fri Aug 07 15:26:20 -0700 2009
| link
Multi column ordering
Hm, I tested the following with Rails 2.3.2:
@@@ Contact.scoped(:order => ’name DESC’)
=> SELECT * FROM
contactsORDER BY contacts.name DESCContact.scoped(:order => ’name DESC’).scoped(:order => ’id DESC’)
=> SELECT * FROM
contactsORDER BY contacts.name DESC@@@
You will see that the second scope is ignored.
Are we talking about different things? ;-)
by Georg Ledermann
binarylogic
Fri Aug 07 15:26:22 -0700 2009
| link
Multi column ordering
Yeah, my fault, it does chain them together when you pass order in an action method:
User.ascend_by_id.ascend_by_email.first(:order => "test") ActiveRecord::StatementInvalid: Mysql::Error: Unknown column ’test’ in ’order clause’: SELECT * FROM `users` ORDER BY test, users.id ASC LIMIT 1
But for me to make this work I would have to alter the default behavior of AR, which I don’t think is a good idea. I’m not sure what to do. I could do some tricky things in the Search object, but I want that to remain consistent with calling the named scopes directly.
by Ben Johnson
binarylogic
Fri Aug 07 15:26:25 -0700 2009
| link
Multi column ordering
I agree with you. My current solution to have mutliple ordering is by adding some named scopes like this:
@@@ ruby named_scope :ordered_by_name, :order => ’last_name ASC, first_name ASC’Contact.search(:ordered_by_name => true)
@@@Somtimes I need to override the predefined searchlogic ordering scopes like this:
@@@ ruby # Preserve insertion order for sorting by date named_scope :descend_by_date, :order => ’date DESC, id DESC’ named_scope :ascend_by_date, :order => ’date ASC, id ASC’ @@@For me, it’s ok to stay with this. We will see if ActiveRecord will merge multiple ordering scopes in the future.
by Georg Ledermann
-
3 comments Created 3 months ago by binarylogic@Ben Johnsonxfrom-lighthousexSome way to deal with i18n (*_translations tables)?|S| openxI tried long time to deal something with model translations tables, but i can’t figure out anything. Maybe somebody will find way to filter data by field from translations table...
This ticket has 0 attachment(s).
Comments
binarylogic
Fri Aug 07 15:26:49 -0700 2009
| link
Some way to deal with i18n (*_translations tables)?
I’m not sure what you are asking.
by Ben Johnson
binarylogic
Fri Aug 07 15:26:54 -0700 2009
| link
Some way to deal with i18n (*_translations tables)?
When using i18n with rails (in activerecord), translated columns are keept in other table (eg. you have table articles, so translated fields like title, content etc are in article_translations table). When i try search something in title of arcticle then i have error - unknown attribute. You have to do something like:
- check if table articles have specified attribute
- if have then process conditions for it
- if not then check if is article_translations table (or ArticleTranslation model will be easier)
- if exists then check attribute and process conditions
- if not then raise error
Im using for now such mechanism in my controller, but it’s not much pretty way...
by Kriss Kowalik
binarylogic
Fri Aug 07 15:26:56 -0700 2009
| link
Some way to deal with i18n (*_translations tables)?
I see what you are saying. The translations / mapping should happen above board, I don’t feel like this is searchlogic responsibility. Does active record do this with their attributes when trying to create / update records?
by Ben Johnson
-
Order only check columns, why not checking additional values requested via SELECT
3 comments Created 3 months ago by ZenCocoonHi Ben,
Looks like the order option only accept valid columns names. What about additional values requested with SELECT.
Example :
SELECT
users.*, COUNT(1) as count FROM ... ORDER BY count ASCIn this case, ordering by count can be extremely useful but doesn't look supported right now.
As quick workaround creating the named "scope ascend_by_count" and "descend_by_count" makes the job but still overload your models far to quick while adding such feature to searchlogic would keep things light and clean.
Thanks again for this great lib and excellent rewrite,
Warm regards,
-- Sebastien Grosjean - ZenCocoonComments
Yeah, I like this.
I often want to order asc/desc using the count of an associated class.
When you use a counter_cache this is pretty easy to do using the counter_cache column but I don't want to use counter_caches everywhere and every time.
Nicolas.
binarylogic
Fri Sep 11 22:32:06 -0700 2009
| link
Hi Sebastien, I'm not sure I follow, how would you dynamically create that scope? I guess you cold make an exception for count if that is an AR default.
Hi Ben,
Didn't look the inside of named scope system yet (I actually should). The fact is that as of now, it seems that you allow as order, only existing column names from the tables queried.
I my case, I'm looking to also allow values defined by the SELECT parameter. It can be "count" as shown in the previous example but also different values depending your named scope
Example :
named_scope :select_with_author_name_as_writter,
:select => "posts.*, authors.name AS writter", :joins => "LEFT OUTER JOIN authors ON authors.id = posts.author_id"Post.select_with_author_name_as_writter.descend_by_writter NoMethodError: undefined method `descend_by_writter' for #<Class:0x101d8dc48>
...Please let me know if it's still blurred.
-
Using OR searches with associated classes fails with Searchlogic::NamedScopes::OrConditions::UnknownConditionError errors
Comments
laserlemon
Thu Oct 01 11:45:50 -0700 2009
| link
I also encountered this and just confirmed it as a bug. The README says that the OR-joined scopes should work with scopes on associations but that doesn't seem to be the case and the code comments make it seem as though it's still pending.
In my fork, I've written a failing test and a possible solution which passes the test.
-
It seems its not working from the form:
- form_for @search do |f| %p = f.text_field :name_or_description_like = f.submit "Search"It works from the console, using Report.name_or_description_like but when I use it in the form I just get a "false" result in the text field, and no filters are applied (I checked the logs).
Let me know if you need any more info (I'm using the latest version of searchlogic and rails 2.3.2).
I also run a test creating a new rails app from scratch with rails 2.3.3 and exactly the same happens, it doesn't get filtered and it shows a "false" string in the form (as a response).
Thanks a lot for a great plugin!
Comments
carlosantoniodasilva
Thu Sep 03 04:53:28 -0700 2009
| link
The same for me, doing this works:
Update.subject_or_body_contains "list"But this does not:
Update.search(:subject_or_body_contains => "list").allRails 2.3.4, SL 2.3.3:
Update.search(:subject_or_body_contains => "list") produces:#<Searchlogic::Search:0xb7457ac4 @klass=Update(id: integer, subject: string, body: string, created_at: datetime, updated_at: datetime), @conditions={:subject_or_body_contains=>false}, current_scopenil
joerichsen
Fri Sep 11 00:15:58 -0700 2009
| link
Same for me Rails 2.3.4 and SL 2.3.3
User.name_or_email_like('Gade').size => 2
User.search(:name_or_email_like => 'Gade').all.size => 379?
There will be exacly the some with:
s = User.search
s.name_or_email_like('Gade')
That's because in Search model in "or" conditions is some bug that set any "or" condition to false(it is visible as I showed earlier but value = false) so no filtering by that condition. Right now I can't find the exact line, but I think that it is somehow connected to validating scope "or" spliting (lib/searchlogic/named_scopes/or_conditions.rb)
Any ideas?Confirming:
>> User.last_name_like_or_first_name_like('tom').size => 1 >> User.search(:last_name_like_or_first_name_like => 'tom').size => 3Same for me:
>> User.login_or_email_like('lec').size SQL (0.4ms) SELECT count(*) AS count_all FROM `users` WHERE ((users.email LIKE '%lec%') OR (users.login LIKE '%lec%')) => 2 >> User.search(:login_or_email_like => "lec").size SQL (0.3ms) SELECT count(*) AS count_all FROM `users` => 23
gavinhughes
Thu Sep 17 00:31:48 -0700 2009
| link
I'm having the same problem.
Ok… I encountered the same problem and checked the source code (quite impressive). After some digging and testing I found the problem, but so far I did not came up with a perfect solution for it. Until then, I have a partial quick fix which I provide at: http://github.com/namxam/searchlogic/
This fix is only working for fully qualified conditions:- name_and_username_like => not working
- name_like_and_user_name_like => working
I hope I can provide a fix for the remaining problem as well
Hi! I finally fixed this problem even for not fully qualified conditions. And also added type convertion, so User.search(:id_or_age_lte, '10') will now work properly.
The fix is here: http://github.com/nebolsin/searchlogic/
That's great news. I hope it will be pulled into the master repository soon!
I am running 2.3.5, but it still appears to be present in this version as well. I am new to searchlogic, so if a work around has been mentioned - I apologize, and point me in the right direction.
note: I did see nebolsins repo above, but have not tried it yet.
-
I'm looking for a way to use Searchlogic to find records which DON'T HAVE records for a given association. For example: "Find all Contacts which have no addresses"
class Contact < ActiveRecord::Base has_many :addresses end class Address < ActiveRecord::Base belongs_to :contact endIn SQL, this query does the job:
SELECT contacts.* FROM contacts LEFT JOIN addresses ON (addresses.contact_id = contacts.id) WHERE (addresses.ID IS NULL)So far as I understand, Searchlogic does not support this. Of course, I can creare a named scope for this:
class Contact named_scope :without_addresses, :joins => 'LEFT JOIN addresses ON addresses.contact_id = contacts.id', :conditions => 'addresses.id IS NULL' endBut I would like to have a more dynamic way, means Searchlogic creating this scope on the fly. What do you think?
Comments
binarylogic
Fri Aug 28 07:04:55 -0700 2009
| link
Searchlogic has a method called left_outer_joins that will create the join for you. But to the best way to solve this is to just add a named scope for each association. I would probably just create another module and do it in there.
Yes, creating scopes the explicit way will work. But I'm looking for a dynamic way. One more example:
Right now, with Searchlogic it's possible to find all contacts with an address in Germany:
>> Contact.search(:addresses_country_equals => 'DE') => "SELECT `contacts`.* FROM `contacts` INNER JOIN `addresses` ON addresses.contact_id = contacts.id WHERE (addresses.country = 'DE') "This creates an INNER JOIN, works fine.
Now, I want to find contacts which don't have an address in Germany. It would be great if Searchlogic could do this, perhaps with this statement:
>> Contact.search(:without_addresses_country_equals => 'DE') => "SELECT `contacts`.* FROM `contacts` LEFT JOIN `addresses` ON (addresses.contact_id = contacts.id AND addresses.country = 'DE') WHERE (addresses.id IS NULL) "The idea is: If the hash key has a "without" in front of the association name, Searchlogic builds the query with the LEFT-JOIN/ID-IS-NULL-Pattern.
IMHO such a feature (implemented in Searchlogic) would be very powerful.
One addition: The whole thing with the left join is required to include contacts which does not have any address, too. You may think my example can be reached with this simple query:
Contact.search(:addresses_country_is_not => 'DE')But this gives a different result set, because it does not include the contacts which have no addresses at all.
-
Exception "undefined method `call' for nil:NilClass"
3 comments Created 2 months ago by slainer68Hi,
I had a weird exception on my production server when using a Searchlogic named_scope, here is
the code :def index @products = Product.available.ascend_by_position.all # ... end
available is a regular named_scope and ascend_by_position is a Searchlogic named_scope on the position column.
The exception :
Error Message: -------------- NoMethodError: undefined method `call' for nil:NilClass Where: ------ orders#index [GEM_ROOT]/gems/activerecord-2.3.4/lib/active_record/named_scope.rb, line 97 Backtrace: ---------- [GEM_ROOT]/gems/activerecord-2.3.4/lib/active_record/named_scope.rb:97:in `ascend_by_position' [GEM_ROOT]/gems/activerecord-2.3.4/lib/active_record/named_scope.rb:181:in `send' [GEM_ROOT]/gems/activerecord-2.3.4/lib/active_record/named_scope.rb:181:in `method_missing' [GEM_ROOT]/gems/activerecord-2.3.4/lib/active_record/base.rb:2143:in `with_scope' [GEM_ROOT]/gems/activerecord-2.3.4/lib/active_record/named_scope.rb:113:in `__send__' [GEM_ROOT]/gems/activerecord-2.3.4/lib/active_record/named_scope.rb:113:in `with_scope' [GEM_ROOT]/gems/activerecord-2.3.4/lib/active_record/named_scope.rb:174:in `method_missing' [RAILS_ROOT]/app/controllers/orders_controller.rb:4:in `index' [GEM_ROOT]/gems/actionpack-2.3.4/lib/action_controller/base.rb:1331:in `send' [GEM_ROOT]/gems/actionpack-2.3.4/lib/action_controller/base.rb:1331:in `perform_action_without_filters' [GEM_ROOT]/gems/actionpack-2.3.4/lib/action_controller/filters.rb:617:in `call_filters' [GEM_ROOT]/gems/actionpack-2.3.4/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark' [GEM_ROOT]/gems/actionpack-2.3.4/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue' [GEM_ROOT]/gems/activesupport-2.3.4/lib/active_support/core_ext/benchmark.rb:17:in `ms' [GEM_ROOT]/gems/activesupport-2.3.4/lib/active_support/core_ext/benchmark.rb:10:in `realtime' [GEM_ROOT]/gems/activesupport-2.3.4/lib/active_support/core_ext/benchmark.rb:17:in `ms' [GEM_ROOT]/gems/actionpack-2.3.4/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue' [GEM_ROOT]/gems/actionpack-2.3.4/lib/action_controller/rescue.rb:160:in `perform_action_without_flash' [GEM_ROOT]/gems/actionpack-2.3.4/lib/action_controller/flash.rb:146:in `perform_action' [GEM_ROOT]/gems/actionpack-2.3.4/lib/action_controller/base.rb:532:in `send' [GEM_ROOT]/gems/actionpack-2.3.4/lib/action_controller/base.rb:532:in `process_without_filters' [GEM_ROOT]/gems/actionpack-2.3.4/lib/action_controller/filters.rb:606:in `sass_old_process' [GEM_ROOT]/gems/haml-2.2.3/rails/../lib/sass/plugin/rails.rb:19:in `process' [GEM_ROOT]/gems/actionpack-2.3.4/lib/action_controller/base.rb:391:in `process' [GEM_ROOT]/gems/actionpack-2.3.4/lib/action_controller/base.rb:386:in `call' [GEM_ROOT]/gems/actionpack-2.3.4/lib/action_controller/routing/route_set.rb:437:in `call' [GEM_ROOT]/gems/actionpack-2.3.4/lib/action_controller/dispatcher.rb:87:in `dispatch' [GEM_ROOT]/gems/actionpack-2.3.4/lib/action_controller/dispatcher.rb:121:in `_call' [GEM_ROOT]/gems/actionpack-2.3.4/lib/action_controller/dispatcher.rb:130:in `build_middleware_stack' /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.5/vendor/rack-1.0.0-git/lib/rack/head.rb:9:in `call' /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.5/vendor/rack-1.0.0-git/lib/rack/head.rb:9:in `call' /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.5/vendor/rack-1.0.0-git/lib/rack/methodoverride.rb:24:in `call' [GEM_ROOT]/gems/actionpack-2.3.4/lib/action_controller/params_parser.rb:15:in `call' [GEM_ROOT]/gems/rails-2.3.4/lib/rails/rack/metal.rb:47:in `call' [GEM_ROOT]/gems/actionpack-2.3.4/lib/action_controller/session/abstract_store.rb:122:in `call' [GEM_ROOT]/gems/activerecord-2.3.4/lib/active_record/query_cache.rb:29:in `call' [GEM_ROOT]/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache' [GEM_ROOT]/gems/activerecord-2.3.4/lib/active_record/query_cache.rb:9:in `cache' [GEM_ROOT]/gems/activerecord-2.3.4/lib/active_record/query_cache.rb:28:in `call' [GEM_ROOT]/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in `call' [GEM_ROOT]/gems/actionpack-2.3.4/lib/action_controller/failsafe.rb:26:in `call' /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.5/vendor/rack-1.0.0-git/lib/rack/lock.rb:11:in `call' /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.5/vendor/rack-1.0.0-git/lib/rack/lock.rb:11:in `synchronize' /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.5/vendor/rack-1.0.0-git/lib/rack/lock.rb:11:in `call' [GEM_ROOT]/gems/actionpack-2.3.4/lib/action_controller/dispatcher.rb:106:in `call' /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/rack/request_handler.rb:95:in `process_request' /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/abstract_request_handler.rb:207:in `main_loop' /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/railz/application_spawner.rb:378:in `start_request_handler' /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/railz/application_spawner.rb:336:in `handle_spawn_application' /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/utils.rb:183:in `safe_fork' /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/railz/application_spawner.rb:334:in `handle_spawn_application' /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/abstract_server.rb:352:in `__send__' /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/abstract_server.rb:352:in `main_loop' /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously' /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/abstract_server.rb:163:in `start' /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/railz/application_spawner.rb:213:in `start' /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/spawn_manager.rb:262:in `spawn_rails_application' /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/abstract_server_collection.rb:126:in `lookup_or_add' /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/spawn_manager.rb:256:in `spawn_rails_application' /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/abstract_server_collection.rb:80:in `synchronize' /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize' /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/spawn_manager.rb:255:in `spawn_rails_application' /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/spawn_manager.rb:154:in `spawn_application' /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/spawn_manager.rb:287:in `handle_spawn_application' /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/abstract_server.rb:352:in `__send__' /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/abstract_server.rb:352:in `main_loop' /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously' /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.5/bin/passenger-spawn-server:61
The weird thing is that I only had this exception on my production server, never had it on my development box.
I tried with and without the .all at the end of line without success. I had to remove the searchlogic named_scope and replace it by a regular named_scope to get rid of this exception.
Comments
binarylogic
Fri Sep 11 22:27:38 -0700 2009
| link
I'm really not sure, its hard for me to determine the problem from this. Is it just this named scope?
Hi Ben, I had this problem again, it seems to be only on this named_scope, strange.
I'll try to investigate more.
austinginder
Tue Nov 17 18:35:02 -0800 2009
| link
I had similar issues between development and production. It may not be related but I fix my problem by downgraded from version 2.3.6 to 2.3.5 on my production server, restarted apache and its working.
-
stack level too deep in merge_scopes_with_or
2 comments Created 2 months ago by dougalcornClass Message < ActiveRecord::Base has_many :addresses, :class_name => "MessageAddress" named_scope :system, :joins => 'LEFT JOIN message_addresses ON message_addresses.message_id = messages.id', :conditions => 'message_addresses.id IS NULL' end Class MessageAddress < ActiveRecord::Base belongs_to :message belongs_to :recipeint, :polymorphic => true named_scope :for_user, lambda { |user| { :conditions => ["blah blah blah", user] } } endNow when I do Message.addresses_for_user_or_system(user) It generates a stack level too deep.
searchlogic (2.3.1) [v] lib/searchlogic/named_scopes/or_conditions.rb:104:in `send' searchlogic (2.3.1) [v] lib/searchlogic/named_scopes/or_conditions.rb:104:in `merge_scopes_with_or' searchlogic (2.3.1) [v] lib/searchlogic/named_scopes/or_conditions.rb:104:in `collect' searchlogic (2.3.1) [v] lib/searchlogic/named_scopes/or_conditions.rb:104:in `merge_scopes_with_or' searchlogic (2.3.1) [v] lib/searchlogic/named_scopes/or_conditions.rb:99:in `create_or_condition' searchlogic (2.3.1) [v] lib/searchlogic/named_scopes/or_conditions.rb:104:in `send' searchlogic (2.3.1) [v] lib/searchlogic/named_scopes/or_conditions.rb:104:in `merge_scopes_with_or' searchlogic (2.3.1) [v] lib/searchlogic/named_scopes/or_conditions.rb:104:in `collect' searchlogic (2.3.1) [v] lib/searchlogic/named_scopes/or_conditions.rb:104:in `merge_scopes_with_or' searchlogic (2.3.1) [v] lib/searchlogic/named_scopes/or_conditions.rb:99:in `create_or_condition' searchlogic (2.3.1) [v] lib/searchlogic/named_scopes/or_conditions.rb:22:in `addresses_for_user_or_without_addresses' searchlogic (2.3.1) [v] lib/searchlogic/named_scopes/or_conditions.rb:22:in `send' searchlogic (2.3.1) [v] lib/searchlogic/named_scopes/or_conditions.rb:22:in `method_missing' vendor/gems/mislav-will_paginate-2.3.11/lib/will_paginate/finder.rb:170:in `method_missing' app/models/message.rb:19:in `for_user'There's a couple problems here. Obviously there's a bug that causes the stack level too deep. But the or using an associated named scope seems to be completely unsupported. So maybe my answer is to just not do that. Oh, and I manually patched my searchlogic 2.3.1 with the latest version of or_condition.rb
Comments
binarylogic
Fri Sep 11 22:25:13 -0700 2009
| link
Yeah, association support is coming, I'm working out a couple of issues. I'll throw this in the test suite.
dougalcorn
Sat Sep 12 06:13:11 -0700 2009
| link
Searchlogic really is great. We're making a lot of use out of it. In this case we ended up just writing our own named scope: break out the sql!
-
Search with empty array returns all results instead of none
1 comment Created 2 months ago by gravisNot sure I understand correctly, it might not be a bug.
If I use :Activity.user_id_equals_any(current_user.friend_ids)
I expect this to be equivalent to
Activity.all(:conditions => {:user_id => current_user.friend_ids})and it's not. The first expression will return all activities if the user doesn't have friends, and the second no activity, as expected.
thanks !
Comments
-
I guess the example below will speak on it's own :
named_scope :select_with_authors,
:joins => "LEFT OUTER JOIN authors ON authors.id = posts.author_id"Post.select_with_authors.descend_by_author_name ActiveRecord::StatementInvalid: Mysql::Error: Not unique table/alias: 'authors': SELECT
posts.* FROMpostsINNER JOINauthorsONauthors.id =posts.author_id LEFT OUTER JOIN authors ON authors.id = posts.author_id ORDER BY authors.name DESCPlease let me know if you like further details.
Comments
-
Could be possible to add OR support even to Search class. I would like do this
Book.search(:title_or_description_like => 'ruby')or in chain
s = Book.search s.title_or_description_like('ruby')Now it produce only
s.conditions => {:title_or_description_like => false}Thanks for wonderful work.
Comments
is this going to be worked on, I just ran into this. A large part of using search logic is the search method, but you currently cant use or statements like: User.search(:gpa_lte_or_null => 4) It just ignores all the conditions.
theworkinggroup
Tue Oct 27 13:40:12 -0700 2009
| link
noticed the same issue. a bit annoying.
-
Please replace line 99 of search.rb
scope = conditions.inject(klass.scoped(current_scope)) do |scope, condition| with
scope = conditions.inject(klass.scoped(current_scope || {})) do |scope, condition| otherwise it doesn't work with Rails 2.2.2This issue was already described here http://binarylogic.lighthouseapp.com/projects/16601/tickets/94-nil-object-error but no solution has been given apart from upgrading to Rails 2.3.x, which sadly is often not possible.
Comments
-
Range values clobbered by search method
0 comments Created about 1 month ago by laserlemonTypecasting Range values isn't working and although Ranges aren't typically passed into the arguments for the search method, it's certainly not impossible (as I found out). The individual scopes work correctly, but when accessed through the
searchmethod, they fall apart. I've forked the repo, added a failing test and presented a solution.Comments
-
An existing named scope that shares its name with one of the model's columns is ignored when accessed via the
searchmethod. Thenormalize_scope_namemethod appends "_equals" with no regard for whether the scope already exists. I've forked the repo, added a failing test and presented a solution.Comments
-
Multiple record copies returned for habtm association
0 comments Created about 1 month ago by infraredI committed a test case that reproduces the problem in http://github.com/infrared/searchlogic/commit/34d3b89122812df2b4fa9a0c8339674ecf25f206
When you have two models joined with has_and_belongs_to_many and you search one of them with something like:
FirstModel.search(:second_models_id_equals_any => [1, 2]).allmultiple copies of the same FirstModel record will be returned if a the record happens to be associated with more than one SecondModels.
Comments
-
For some reason, when I try to do an is(#) or equals(#) or _eq(#), I always get an error about there being the wrong number of arguments.
Table:
Workflow(id: integer, created_by: integer, held_by: integer, prefix: integer, project_id: integer, form_id: integer, fields: text, subject: string, priority: integer, status: integer, due_date: datetime, created_at: datetime, updated_at: datetime)
Records:
+----+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+ | id | cre... | hel... | prefix | pro... | for... | fields | sub... | pri... | status | due... | cre... | upd... | +----+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+ | 4 | 1 | 1 | 0 | 3 | 9 | 28d... | | 2 | 0 | | 200... | 200... | | 5 | 1 | 1 | 0 | 2 | 7 | | | 2 | 0 | | 200... | 200... | +----+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+
Trying to execute Workflow.status_is(0) results in:
ArgumentError: wrong number of arguments (2 for 1) from C:/Ruby/lib/ruby/gems/1.8/gems/searchlogic-2.3.5/lib/searchlogic/named_scopes/conditions.rb:93:in `attribut e_condition' from C:/Ruby/lib/ruby/gems/1.8/gems/searchlogic-2.3.5/lib/searchlogic/named_scopes/conditions.rb:93:in `create_p rimary_condition' from C:/Ruby/lib/ruby/gems/1.8/gems/searchlogic-2.3.5/lib/searchlogic/named_scopes/conditions.rb:151:in `call' from C:/Ruby/lib/ruby/gems/1.8/gems/searchlogic-2.3.5/lib/searchlogic/named_scopes/conditions.rb:151:in `scope_o ptions' from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/named_scope.rb:91:in `call' from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/named_scope.rb:91:in `named_scope' from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/named_scope.rb:96:in `call' from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/named_scope.rb:96:in `status_equals' from C:/Ruby/lib/ruby/gems/1.8/gems/searchlogic-2.3.5/lib/searchlogic/named_scopes/conditions.rb:175:in `send' from C:/Ruby/lib/ruby/gems/1.8/gems/searchlogic-2.3.5/lib/searchlogic/named_scopes/conditions.rb:175:in `create_ alias_condition' from C:/Ruby/lib/ruby/gems/1.8/gems/searchlogic-2.3.5/lib/searchlogic/named_scopes/conditions.rb:83:in `create_c ondition' from C:/Ruby/lib/ruby/gems/1.8/gems/searchlogic-2.3.5/lib/searchlogic/named_scopes/conditions.rb:66:in `method_m issing' from C:/Ruby/lib/ruby/gems/1.8/gems/searchlogic-2.3.5/lib/searchlogic/named_scopes/association_conditions.rb:19: in `method_missing' from C:/Ruby/lib/ruby/gems/1.8/gems/searchlogic-2.3.5/lib/searchlogic/named_scopes/association_ordering.rb:27:in `method_missing' from C:/Ruby/lib/ruby/gems/1.8/gems/searchlogic-2.3.5/lib/searchlogic/named_scopes/ordering.rb:30:in `method_mis sing' from C:/Ruby/lib/ruby/gems/1.8/gems/searchlogic-2.3.5/lib/searchlogic/named_scopes/or_conditions.rb:24:in `metho d_missing' from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:1833:in `method_missing' from (irb):11Comments
laserlemon
Tue Oct 06 08:20:19 -0700 2009
| link
It looks like this may be my fault. The problem is that
ActiveRecord::Base.attribute_conditiononly started accepting two arguments when it started supporting end-exclusive ranges, starting at ActiveRecord 2.3.1. I see you're using 2.2.2, which is causing the error.Is it worth having a version check in there for backwards compatibility?
laserlemon
Tue Oct 06 08:32:37 -0700 2009
| link
Could be. I defer to Ben.
-
Search through association with column named "name" fails
1 comment Created about 1 month ago by naven87Take the following models
Earnings: belongs_to :period
Period: has_many :earnings
if Period has a string column titled "name" the following search fails
Earnings.period_name_like("Q309") with a MySQL error that the Table/Alias periods is not unique. If I look at the generated MySQL, it creates both an inner and and outer join on the periods table against the earnings table.If I instead call Earning.period_id_is(7) it works fine and no error is generated. The MySQL query only includes one outer join and no inner join.
Comments
So after more digging, I found that the column name was irrelevant, the real issue was any default scope on the model is merged into the query without concern for overlap. So if the default scope has a join or include in it, that will be included directly in the final query and if the searchlogic portion uses the same table name it will add it's own join into the query which can create the problem described
-
I am trying to use jqGrid's search function with searchlogic. The rub of it is jqGrid's aliases for 'less than or equal to' and a few others do not map onto searchlogic's. Right now, I am creating a hash constant in the application controller to the mapping. What I would love is to have a configuration file that would allow me to extend the aliases. This way, I could drop that config file in any app I so chose that I wanted to use both libraries in concert. Anyway, thank you for such a wonderful plugin and if you would like me to write up a spec, I would be more than happy to.
cheers,
-xnComments
-
in the server console, parameters coming in fine:
Processing GamesController#index (for 127.0.0.1 at 2009-10-16 07:12:36) [GET]
Parameters: {"commit"=>"Submit", "search"=>{"year_ge"=>"1920", "order"=>"", "year_le"=>"2009", "segment"=>"reg"}}but gets passed incorrectly to the scope:
NoMethodError (undefined method `year_ge' for {}:Hash):
Comments
-
Ben seems to show examples of "User.age_greater_than(20)" but age as an attribute is often used in models as a virtual attribute which calculates the current age from DOB.
When I use age as a virtual attribute and search on it, I get a "undefined method `age_greater_than' for #<Class:0x48fff80>"
What am I missing?
Comments
-
searchlogic uses NULL value on search by date (created_at_gte)
3 comments Created 26 days ago by spovichDoing a simple search on the created_at column will produce SQL that has a NULL value for the date.
In the form, I input in ISO date format (YYYY-MM-DD), and the values shows in the params in the logs:
Parameters: {"commit"=>"Search", "action"=>"index", "controller"=>"foos", "search"=>{"city_like"=>"", "created_at_gte"=>"2009-04-13"}}
But the resulting SQL gives a NULL for the date:
SELECT * FROM "foos" WHERE (foos.created_at >= NULL)
Comments
Ok, the issue is that searchlogic silently makes a nil when you provide a date for a datetime field. However, ruby converts date to time without a problem:
Time.parse "Jan 1, 2009" => Thu Jan 01 00:00:00 -0800 2009
So, this seems to be a bug to me. I'll write some failing specs if you agree that it should be able to convert a date to a datetime when searching.
Taking another look and I see search_spec.rb line 267 is a search of a datetime that is given an date, so we agree that a Date should be upcast to a dateTime.
The specs all pass for me using the SQLite db, but trying the same thing with a stock rails app 2.3.4 and ruby 1.8.7 in IRB (console) with Postgres 8.3 and latest pg gem (0.8.0) will fail (running on OS X):
>> s = Message.search
=> #<Searchlogic::Search:0x35e6ad4 @klass=Message(id: integer, type: string, uuid: string, title: string, description: text, created_at: datetime, updated_at: datetime), @current_scope=nil>
>> s.created_at_after = 'Jan 1, 2009' => "Jan 1, 2009" >> s.created_at_after => nil
I don't know how to make this fail in SQLIte, but it is clearly failing in postgres. Any ideas?
Thanks,
John -
This is what my search form sends:
"search"=>{"value_equals"=>"0..15000", "property_type_id"=>"1"}
The value_equals parameter is not read as a proper range, like from 0 to 15000 and while it should display as a result a record with value "10000", none is shown.
Comments
-
given a model
Company with attribute
nameand a model
Contact with attributes
first_name and last_nameThe Models are associated like this:
Contact belongs_to Company Company has_many ContactsI wish to make a search field into which I can type a portion of either the contact's first name, the contact's last name or the company name.
This works:
@contacts = Contact.company_name_like(params[:search])This works:
@contacts = Contact.first_name_or_last_name_like(params[:search])This does NOT work:
@contacts = Contact.company_name_or_first_name_or_last_name_like(params[:search]) It returns this error:
"The condition 'company_name' is not a valid condition, we could not find any scopes that match this."Evidently the scope company_name works by itself but not in combination with the other two. And the other two work, but not with company_name. I can only assume this has to do with the association and I am missing something obvious. Can anyone point out how to do it correctly?
The last example (company_name_or_first_name_or_last_name_like) worked in an earlier version of my app, when company was an attribute of Contact. When I made Company a separate model it stopped working.
I believe I have the current version of binarylogic-searchlogic. Rails version is 2.3.2, in development mode with standard sqlite database.
Thank you.
Comments
-
I love search logic, but cannot get it to run in production mode. I found out that the cache_classes setting was the culprit. I know searchlogic works dynamically, but is there a way to enable searchlogic with class_caching?
When the classes are not cached I get:
undefined methodcached_tags_contains' for #<Array:0x4e064c0> or<br/> undefined methodid_contains' for #<Array:0x4e064c0>Comments
-
For some reason Searchlogic::Search.respond_to?(:paginate) returns false, even though you can call paginate on it.
This was messing up Hobo, so I monkey patched it:
class Searchlogic::Search
def respond_to?(symbol) return true if symbol === :paginate old_respond_to? symbol end endComments
-
The change log states that modifiers were added quite a while ago. However, I can't seem to use them. I keep getting errors like: "The lower_of_first_name_eq is not a valid condition. You may only use conditions that map to a named scope"
Are modifiers available in the latest release?
Comments
-
if Car has_many Tires
Tire has an integer column called sizeI should be able to do :
Car.tires_size_equals([4,5,6])
That fails though. I am able to do a single item though like Car.tires_size_equals(4)
Here is the error:
/Library/Ruby/Gems/1.8/gems/searchlogic-2.3.6/lib/searchlogic/named_scopes/conditions.rb:111: warning: multiple values for a block parameter (2 for 1)from /Library/Ruby/Gems/1.8/gems/searchlogic-2.3.6/lib/searchlogic/named_scopes/conditions.rb:173ActiveRecord::PreparedStatementInvalid: wrong number of bind variables (2 for 1) in: support_regions.region_id IN (?)
from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/base.rb:2398:in `raise_if_bind_arity_mismatch' from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/base.rb:2350:in `replace_bind_variables' from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/base.rb:2341:in `sanitize_sql_array' from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/base.rb:2230:in `sanitize_sql' from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/base.rb:1494:in `merge_conditions' from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/base.rb:1492:in `each' from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/base.rb:1492:in `merge_conditions' from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/base.rb:1804:in `add_conditions!' from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/base.rb:1687:in `construct_finder_sql' from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/base.rb:1548:in `find_every' from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/base.rb:615:in `find' from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/named_scope.rb:181:in `send' from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/named_scope.rb:181:in `method_missing' from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/base.rb:2143:in `with_scope' from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/named_scope.rb:113:in `__send__' from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/named_scope.rb:113:in `with_scope' from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/named_scope.rb:174:in `method_missing' from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/named_scope.rb:188:in `load_found' from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/named_scope.rb:166:in `proxy_found' from /Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/named_scope.rb:109:in `inspect' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb.rb:302:in `output_value' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb.rb:151:in `eval_input' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb.rb:263:in `signal_status' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb.rb:147:in `eval_input' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb.rb:146:in `eval_input' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb.rb:70:in `start' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb.rb:69:in `catch' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb.rb:69:in `start'Comments
-
What is the "right" way to search on boolean columns?
>> Invite.code_equals('F0LzDetW') => [#<Invite id: 29, created_at: "2009-11-14 20:53:51", updated_at: "2009-11-14 20:53:51", code: "F0LzDetW", table: nil, item: 11, accepted: nil, email: "bot@........lv">] >> Invite.code_equals('F0LzDetW').accepted_equals(false) => [] >> Invite.code_equals('F0LzDetW').accepted_equals(nil) => [] >> Invite.code_equals('F0LzDetW').accepted_does_not_equal(false) => [] >> Invite.code_equals('F0LzDetW').accepted_does_not_equal(nil) => [] >>Comments
-
I found some old issues, concerning the date_select helper. It looks like there should be support to use this helper in combination with searchlogic.
But when I use <%= f.date_select :start_after, :include_blank => true %> it fails with
"The is not a valid condition. You may only use conditions that map to a named scope"Comments
- @Ben Johnson▾
- associations▾
- conditions▾
- from-lighthouse▾
- group▾
- grouping▾
- named_scope▾
- order▾
- order_by▾
- search▾
- |S| new▾
- |S| open▾
- Apply to Selection
-
Change Color…
Preview:preview
- Rename…
- Delete












Yeah, I see what you're doing, AR supports this, I just need to figure out how to tap into it.