Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

ArgumentError (comparison of String with 0 failed) #175

Open
TheOddLinguist opened this Issue · 11 comments

4 participants

@TheOddLinguist

Error's coming from:
https://github.com/scambra/devise_invitable/blob/master/lib/devise_invitable/inviter.rb#L18

In development (on a Mac), it seemed to work fine. Deployed to Heroku, and I'm getting this error. Do I have a configuration issue? Or perhaps that value should be cast to an integer before comparison? If so, I can submit a quick pull request if that makes it easier. Thanks either way.

@scambra
Owner

Can you check database? Is invitation_limit an integer?

@TheOddLinguist

Migration:

t.integer    :invitation_limit, :default => 0

Schema:

t.integer  "invitation_limit", :default => 0

Console:

irb(main):001:0> User.invitation_limit.class
=> Fixnum

irb(main):002:0> User.first.invitation_limit.class
User Load (18.7ms)  SELECT "users".* FROM "users" LIMIT 1
=> Fixnum

Let me know if you need any more info. Thanks.

@scambra
Owner

Do you know user which was inviting? Can you test invitation_limit in that user?

@TheOddLinguist

I've got 5 set in the initializer, 0 set on all users in db. The plan is to not allow invites unless I set the limit to nil on a given user. I set the 5 since it seemed like you needed a value there for the db value to take effect.

@scambra
Owner

Ok. Is it reproducible? Can you reproduce from the console? calling user.has_invitations_left? or user.invitation_limit

@TheOddLinguist

Interestingly, it's fine from the console:

irb(main):004:0> User.first.has_invitations_left?
User Load (4.9ms)  SELECT "users".* FROM "users" LIMIT 1
=> false
irb(main):005:0> User.first.invitation_limit
User Load (8.3ms)  SELECT "users".* FROM "users" LIMIT 1
=> 0
irb(main):006:0> User.first.invitation_limit.class
User Load (12.2ms)  SELECT "users".* FROM "users" LIMIT 1
=> Fixnum

But when I try to send an invitation from this user's account, I get this error:

2012-02-23T08:10:23+00:00 app[web.1]: Started POST "/users/invitation" for 98.235.36.57 at 2012-02-23 08:10:23 +0000
2012-02-23T08:10:23+00:00 app[web.1]: 
2012-02-23T08:10:23+00:00 app[web.1]: ArgumentError (comparison of String with 0 failed):
2012-02-23T08:10:23+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/devise_invitable-1.0.0/lib/devise_invitable/inviter.rb:18:in `>'
2012-02-23T08:10:23+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/devise_invitable-1.0.0/lib/devise_invitable/inviter.rb:18:in `has_invitations_left?'
2012-02-23T08:10:23+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/devise_invitable-1.0.0/app/controllers/devise/invitations_controller.rb:55:in `has_invitations_left?'

This isn't an emergency or anything. It's a production environment, but this app is still in development. I was just intrigued since it functioned properly on my laptop in development.

If you think of anything else you'd like me to check, let me know. Otherwise, don't worry about it too much. Haven't seen anyone else with this issue, so I'm guessing it's something about my configuration.

@scambra
Owner

I'm intrigued too. It should never return a string

@kahnachouhan

I've faced the same issue,when I run my app on production. Any solution for this ?

@scambra
Owner

A failing test would be useful to reproduce it and fix it. If you don't know how to write the test or you cannot reproduce it in a test, I would need a sample application to reproduce it.

@scambra
Owner

Can someone with this problem write a failing test? Or provide a sample app?

@austinwang

FYI, we had the same error only on production and a restart fixed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.