wrong number of arguments (2 for 1) find_by_sql following update to 3.1.1 #3452

Closed
algritz opened this Issue Oct 27, 2011 · 7 comments

3 participants

@algritz

I updated my app from Rails 3.0.9 to 3.1.1, I'm now getting a lot of errors of that type : wrong number of arguments (2 for 1)

Tried to nail it down by using a simple find command:

irb(main):002:0> User.first
ArgumentError: wrong number of arguments (2 for 1)
from APP_PATH/bin/ruby/1.8/gems/activerecord-3.1.1/lib/active_record/relation.rb:111:in find_by_sql'
from APP_PATH/bin/ruby/1.8/gems/activerecord-3.1.1/lib/active_record/relation.rb:111:in
to_a'
from APP_PATH/bin/ruby/1.8/gems/activerecord-3.1.1/lib/active_record/relation/finder_methods.rb:376:
in find_first'
from APP_PATH/bin/ruby/1.8/gems/activerecord-3.1.1/lib/active_record/relation/finder_methods.rb:122:
in
first'
from D:0:in __send__'
from D:0:in
first'
from (irb):2
from :0

EDIT, I should add more details :

Windows 7 64 Bits
Ruby 1.8.7 (Patch 352)
Rails 3.1.1

@alindeman

Any default_scope on User?

@algritz

nope, here's the 'meat' of the user model :

class User < ActiveRecord::Base
attr_accessor :password
attr_accessible :name, :email, :password, :password_confirmation, :creation_code
email_regex = /\A[\w+-.]+@[a-z\d-.]+.[a-z]+\z/i

validates :creation_code, :presence => true

validates :name, :presence => true,
:length => { :maximum => 50 }
validates :email, :presence => true,
:format => { :with => email_regex },
:uniqueness => { :case_sensitive => false }
# Automatically create the virtual attribute 'password_confirmation'.
validates :password, :presence => true,
:confirmation => true,
:length => { :within => 6..40 }

before_save :encrypt_password

has_many :sales_listings, :dependent => :destroy

@algritz

Update, running this will provide an output :

User.find_by_sql("select * from users where id = 2")
=> MY_USER_INFO

@algritz

I've created a new project to test the User.first function, it does work. This looks to me as it is an "update issue".

@algritz

Hum, I trashed my /bin folder, ran a bundle install, still didn't fixed the issue (same error)

@algritz

Nailed it : 'Gem Slim_scrooged' was causing the issue, I removed it form my bundle and it worked.

https://github.com/sdsykes/slim_scrooge

@algritz algritz closed this Oct 27, 2011
@aarthiraj561

Hi i am facing the same problem, as soon as i commented the slim_scrooge line in my Gemfile i started working..

But may i know what is the alternative to slim_scrooge?? as i want to get only those columns which i need and my codebase i quite large to sit and change everywhere manually... although its a very bad idea...!

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment