I keep getting the error ArgumentError: wrong number of arguments (0 for 1)
for my default_scope
which is default_scope { where("#{table_name}.tenant_id IS NULL") }
It keeps giving me this error and I don't understand why. I have the default scope in my users model.
Update:
Error output if using rails console:
ArgumentError: wrong number of arguments (0 for 1) from /home/evan/Apps/demo-application/app/models/user.rb:18:in `hash' from /home/evan/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-4.0.4/lib/active_record/scoping.rb:64:in `value_for' from /home/evan/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.4/lib/active_support/per_thread_registry.rb:40:in `public_send' from /home/evan/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.4/lib/active_support/per_thread_registry.rb:40:in `block in method_missing' from /home/evan/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-4.0.4/lib/active_record/scoping/default.rb:123:in `ignore_default_scope?' from /home/evan/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-4.0.4/lib/active_record/scoping/default.rb:134:in `evaluate_default_scope' from /home/evan/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-4.0.4/lib/active_record/scoping/default.rb:110:in `build_default_scope' from /home/evan/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-4.0.4/lib/active_record/relation.rb:554:in `with_default_scope' from /home/evan/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-4.0.4/lib/active_record/relation.rb:582:in `exec_queries' from /home/evan/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-4.0.4/lib/active_record/relation.rb:471:in `load' from /home/evan/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-4.0.4/lib/active_record/relation.rb:220:in `to_a' from /home/evan/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-4.0.4/lib/active_record/relation.rb:573:in `inspect' from /home/evan/.rvm/gems/ruby-2.0.0-p195/gems/railties-4.0.4/lib/rails/commands/console.rb:90:in `start' from /home/evan/.rvm/gems/ruby-2.0.0-p195/gems/railties-4.0.4/lib/rails/commands/console.rb:9:in `start' from /home/evan/.rvm/gems/ruby-2.0.0-p195/gems/railties-4.0.4/lib/rails/commands.rb:62:in `<top (required)>' from bin/rails:4:in `require'
The hash
is in my user model as below.
def User.new_remember_token SecureRandom.urlsafe_base64 end def User.hash(token) Digest::SHA1.hexdigest(token.to_s) end private def create_remember_token self.remember_token = User.hash(User.new_remember_token) end
Error output if using rails server:
ArgumentError - wrong number of arguments (0 for 1): activerecord (4.0.4) lib/active_record/scoping.rb:70:in `set_value_for' activesupport (4.0.4) lib/active_support/per_thread_registry.rb:40:in `block in method_missing' activerecord (4.0.4) lib/active_record/scoping/default.rb:127:in `ignore_default_scope=' activerecord (4.0.4) lib/active_record/scoping/default.rb:140:in `ensure in evaluate_default_scope' activerecord (4.0.4) lib/active_record/scoping/default.rb:140:in `evaluate_default_scope' activerecord (4.0.4) lib/active_record/scoping/default.rb:110:in `build_default_scope' activerecord (4.0.4) lib/active_record/relation.rb:554:in `with_default_scope' activerecord (4.0.4) lib/active_record/relation.rb:582:in `exec_queries' activerecord (4.0.4) lib/active_record/relation.rb:471:in `load' activerecord (4.0.4) lib/active_record/relation.rb:220:in `to_a' activerecord (4.0.4) lib/active_record/relation/finder_methods.rb:316:in `find_take' activerecord (4.0.4) lib/active_record/relation/finder_methods.rb:66:in `take' activerecord (4.0.4) lib/active_record/relation/finder_methods.rb:49:in `find_by' activerecord (4.0.4) lib/active_record/querying.rb:6:in `find_by' app/helpers/sessions_helper.rb:16:in `current_user' app/helpers/sessions_helper.rb:19:in `signed_in?'
And the relevant rails methods:
def ignore_default_scope? # :nodoc: ScopeRegistry.value_for(:ignore_default_scope, self) end def ignore_default_scope=(ignore) # :nodoc: ScopeRegistry.set_value_for(:ignore_default_scope, self, ignore) end