#14 ✓resolved

check_box and _is_not_nil

Reported by mollo | October 22nd, 2008 @ 10:00 AM

Hi Ben,

I'm trying check_box tag in form with _is_not_nil condition :

Just put in the view :

= m.check_box :notification_date_is_not_nil

notification_date is a db attribute (DATE)

Params[:search] are correctly mapped :

{"search"=>{"conditions"=>{ "notification_date_is_not_nil"=>"1",

But search fail with this error :

ArgumentError in stuffController#index

wrong number of arguments (0 for 1)

to_conditions' vendor/plugins/searchgasm-1.5.3/lib/searchgasm/condition/not_nil.rb:13:into_conditions' vendor/plugins/searchgasm-1.5.3/lib/searchgasm/condition/base.rb:92:in
`sanitize' ../.. snip

Now for testing I force a condition in the controler :

@search.conditions.notification_date_is_not_nil # No errors, but has no Effect in the query.

and :




Bang with wrong number of arguments (0 for 1)

Who is wrong ? me or searchgasm


Comments and changes to this ticket

  • Ben Johnson

    Ben Johnson October 23rd, 2008 @ 11:32 AM

    • State changed from “new” to “resolved”

    Yep, thanks for letting me know about this. I fixed this and you should be all set now. Let me know if you have any other issues.

  • Ben Johnson

    Ben Johnson October 24th, 2008 @ 12:00 PM

    Searchgasm only ignores blank values. 0 is a meaningful value. If rails didn't add in the hidden field all would work fine. But instead you need to set the "unchecked value" to "" or nil.

    search.condition.name_not_nil = 0

    Is basically saying "find records where they are not not nil".

    If you do this:

    f.check_box :name_not_nil, {}, "1", nil

    This will work as expected. I have been thinking about changing this default behavior if the form object is a searchgasm object. But I am hesitant to change rails defaults because it's not what people expect. But this seems to make sense here.

    Let me know if you have any other problems.

  • Ben Johnson

    Ben Johnson October 28th, 2008 @ 02:05 AM

    • State changed from “resolved” to “open”
    • Assigned user set to “Ben Johnson”

    I am still working on this. I am adding in some tests and trying to recreate your problem.

  • Ben Johnson

    Ben Johnson October 30th, 2008 @ 11:26 AM

    • State changed from “open” to “resolved”

    Awesome, glad to hear its working out.

  • yolo

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Provides common named scopes and object based searching.

People watching this ticket