wrong number of arguments (1 for 0) Hartl chapter 10...bundle exec rake db:populate
railstutorial.org, ruby-on-rails
Solution
Use
users = User.all.limit(6)
or just
users = User.limit(6)
The 'all' method doesn't take parameters. http://apidock.com/rails/ActiveRecord/Scoping/Named/ClassMethods/all
Problem
I'm new on rails an doing the Hartl Tutotial right now. I ran into an error while populating the DB with ``` bundle exec rake db:populate ``` This is my sample_date.rake ``` namespace :db do desc "Fill database with sample data" task populate: :environment do admin = User.create!(name: "Example User", email: "example@railstutorial.org", password: "foobar", password_confirmation: "foobar", admin: true) 99.times do |n| name = Faker::Name.name email = "example-#{n+1}@railstutorial.org" password = "password" User.create!(name: name, email: email, password: password, password_confirmation: password) end users = User.all(limit: 6) 50.times do content = Faker::Lorem.sentence(5) users.each { |user| user.microposts.create!(content: content) } end end end ``` The error refers to line 24 to the argument "Users.all" but what the hack is the problem here???? I checked all my rb-files but they match with tutorial the tags. ``` $ bundle exec rake db:populate --trace ** Invoke db:populate (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:populate rake aborted! ArgumentError: wrong number of arguments (1 for 0) c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.1.1/lib /active_record/scoping/named.rb:24:in `all' C:/Users/Christian/Documents/Aptana Studio 3 Workspace/Tutorial3/lib/tasks/sample_data.rake:19:in `block (2 levels) in c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.3.2/lib/rake/task.rb:240:in `call' c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.3.2/lib/rake/task.rb:240:in `block in execute' c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.3.2/lib/rake/task.rb:235:in `each' c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.3.2/lib/rake/task.rb:235:in `execute' c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.3.2/lib/rake/task.rb:179:in `block in invoke_with_call_cha c:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize' c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.3.2/lib/rake/task.rb:172:in `invoke_with_call_chain' c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.3.2/lib/rake/task.rb:165:in `invoke' c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.3.2/lib/rake/application.rb:150:in `invoke_task' c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.3.2/lib/rake/application.rb:106:in `block (2 levels) in to c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.3.2/lib/rake/application.rb:106:in `each' c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.3.2/lib/rake/application.rb:106:in `block in top_level' c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.3.2/lib/rake/application.rb:115:in `run_with_threads' c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.3.2/lib/rake/application.rb:100:in `top_level' c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.3.2/lib/rake/application.rb:78:in `block in run' c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.3.2/lib/rake/application.rb:176:in `standard_exception_han c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.3.2/lib/rake/application.rb:75:in `run' c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.3.2/bin/rake:33:in `<top (required)>' c:/RailsInstaller/Ruby1.9.3/bin/rake:23:in `load' c:/RailsInstaller/Ruby1.9.3/bin/rake:23:in `<main>' Tasks: TOP => db:populate ``` This is my Gem-File: source 'https://rubygems.org' ``` gem 'rails', '4.1.1' gem "twitter-bootstrap-rails" gem "bootstrap-sass", '~> 3.1.1.1' gem 'sprockets', '~> 2.11.0' gem 'bcrypt-ruby', '3.1.2' gem 'faker', '1.1.2' gem 'will_paginate', '3.0.5' gem 'bootstrap-will_paginate', '0.0.10' group :development, :test do gem 'sqlite3' gem 'rspec-rails', '2.14.2' end group :assets do gem 'sass-rails', '~> 4.0.3' gem 'uglifier', '>= 1.3.0' gem 'coffee-rails', '~> 4.0.0' end gem 'jquery-rails' group :test do gem 'capybara', '2.2.1' end group :production do gem 'rails_12factor' end gem 'turbolinks' gem 'jbuilder', '~> 2.0' gem 'sdoc', '~> 0.4.0', group: :doc gem 'tzinfo-data', platforms: [:mingw, :mswin] ``` For any help very greatful...I got stuck here!