opened
bnussey
username_0
Recently I've noticed that the date filtering is not working correctly.

The logs indicate that the params are being correctly passed through, and they are also still in the URL.. The count works fine, but the actual querying does not take place. Any ideas what could be going on here? I did recently upgrade to `Ruby 2.2` but I'm not sure if that's related.

        Started GET "/admin/users?utf8=%E2%9C%93&q%5Brole_contains%5D=read&commit=Filter&order=id_desc" for 50.17.182.190 at 2015-11-13 05:05:06 +0000
        Processing by Admin::UsersController#index as HTML
          Parameters: {"utf8"=>"✓", "q"=>{"role_contains"=>"read"}, "commit"=>"Filter", "order"=>"id_desc"}
          User Load (0.4ms)  SELECT  "users".* FROM "users"  WHERE "users"."id" = 1  ORDER BY "users"."id" ASC LIMIT 1
           (2.0ms)  SELECT COUNT(*) FROM "users"  WHERE ("users"."role" ILIKE '%read%')
           (0.3ms)  SELECT COUNT(*) FROM "users"  WHERE ("users"."role" ILIKE '%read%') AND (created_at > '2015-11-01 00:00:00.000000')
           (0.2ms)  SELECT COUNT(*) FROM "users"  WHERE ("users"."role" ILIKE '%read%') AND (created_at > '2015-11-09 00:00:00.000000')
           (0.3ms)  SELECT COUNT(count_column) FROM (SELECT  1 AS count_column FROM "users"  WHERE ("users"."role" ILIKE '%read%') LIMIT 30 OFFSET 0) subquery_for_count
          CACHE (0.0ms)  SELECT COUNT(count_column) FROM (SELECT  1 AS count_column FROM "users"  WHERE ("users"."role" ILIKE '%read%') LIMIT 30 OFFSET 0) subquery_for_count
          CACHE (0.0ms)  SELECT COUNT(*) FROM "users"  WHERE ("users"."role" ILIKE '%read%')
      CACHE (0.0ms)  SELECT COUNT(count_column) FROM (SELECT  1 AS count_column FROM "users"  WHERE ("users"."role" ILIKE '%read%') LIMIT 30 OFFSET 0) subquery_for_count
      User Load (0.7ms)  SELECT  "users".* FROM "users"  WHERE ("users"."role" ILIKE '%read%')  ORDER BY "users"."id" desc LIMIT 30 OFFSET 0
Date filtering is not working
issue
created
jonatack
username_1
What SQL are you seeing if you run this in the console? 

```ruby
User.ransack(created_at_gteq: "2015-11-01", created_at_lteq: "2015-11-30").result.to_sql
```

And which attributes does this show?
```ruby
User.ransackable_attributes
```
comment
created
jonatack
username_1
Closing this for now since am unable to reproduce the issue. Will re-open on your reply.
comment
closed
jonatack
username_1
issue
created
bnussey
username_0
Hey @username_1  sorry for delay, and appreciate your guidance. When I do that, I get this:

    Loading development environment (Rails 4.1.0)
    irb(main):001:0> User.ransack(created_at_gteq: "2015-11-01", created_at_lteq: "2015-11-     30").result.to_sql
    => "SELECT \"users\".* FROM \"users\""
comment
created
bnussey
username_0
I've noticed some weirdness around dates since I upgraded to Ruby 2.2 `ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]`. For example when creating items through the API and passing in dates, I've had to pass in the month, day, year as separate params. What version of Ruby are you on?
comment
created
jonatack
username_1
The console example above works fine for me with Ruby 1.9.3, 2.0.0, and 2.2.3.
You didn't reply to my 2nd question. 
I suspect your problem is in your code and not a bug in Ransack.
comment
created
bnussey
username_0
Hey @username_1 well it seems to be happening on every model, not just the User model, which leads me to believe it might not be code related.. What version of rails are you on? 

Sorry I missed that, here it is below:
```
Loading development environment (Rails 4.1.0)
irb(main):001:0> User.ransackable_attributes
=> ["id", "email", "encrypted_password", "reset_password_token", "reset_password_sent_at", "remember_created_at", "sign_in_count", "current_sign_in_at", "last_sign_in_at", "current_sign_in_ip", "last_sign_in_ip", "created_at", "updated_at", "rol
e", "currency", "first_name", "last_name", "address", "phone_number", "unique_session_id", "country", "free_trial_offered", "favorite_category_id", "last_seen_at", "trial_end", "trial_elapsed", "trial_checked", "favorite_category_subscribe", "re
ferrals_id", "welcome_email", "failure_email", "onboarding_call", "api_key"]
```
comment
created
jonatack
username_1
Please provide a stand-alone script in a gist like [this one](https://gist.github.com/username_1/5df41a0edb53b7bad989) with the full code and test to show that it is really an issue with Ransack..
comment
created
bnussey
username_0
Hey @username_1 I fixed it by upgrading to `Rails 4.2.5`
I believe it might be loosely related to https://github.com/rails/rails/commit/e88da370f190cabd1e9750c5b3531735950ab415
comment
created
jonatack
username_1
OK great, glad you found it.
comment