Sam
Sam

Reputation: 5250

Throws wrong number of arguments error

Rails active record throws the following error.

 irb(main):030:0* Subscription.where(valid_until: nil).where.not(activated_on: nil)
    ArgumentError: wrong number of arguments (given 0, expected 1+)

There are 5 nil entries for valid_until

irb(main):032:0> Subscription.where(valid_until: nil).count
2017-05-02 19:03:43.867 [MEH]  (0.6ms)  SELECT COUNT(*) FROM "pti_subscriptions" WHERE "pti_subscriptions"."valid_until" IS NULL
=> 5

The problem is with where.not. Any ideas?

Upvotes: 0

Views: 464

Answers (1)

Divya Sharma
Divya Sharma

Reputation: 556

In Rails 4 where.not is introduced. You are working on Rails 3.2.13, so you have to do something like this:

 Subscription.where('valid_until IS NULL and activated_on IS NOT NULL')

Upvotes: 4

Related Questions