Skip to content

Instantly share code, notes, and snippets.

@crova
Last active June 8, 2016 08:15
Show Gist options
  • Save crova/1baa98b74f3c55ee208806f14725ff78 to your computer and use it in GitHub Desktop.
Save crova/1baa98b74f3c55ee208806f14725ff78 to your computer and use it in GitHub Desktop.
irb(main):016:0> acct_info
=> {"first_name"=>"xxx", "last_name"=>"xxx", "email"=>"xxx", "company"=>"xxx", "address"=>"xxx", "city"=>"xx", "zip_code"=>"xxx", "country"=>"xxx"}
irb(main):017:0>
irb(main):017:0> acct_info.each do |x|
irb(main):018:1* Acct.create! x.to_a
irb(main):019:1> end
ArgumentError: When assigning attributes, you must pass a hash as an argument.
from /var/lib/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/attribute_assignment.rb:25:in `assign_attributes'
from /var/lib/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/core.rb:566:in `init_attributes'
from /var/lib/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/core.rb:281:in `initialize'
from /var/lib/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/inheritance.rb:61:in `new'
from /var/lib/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/inheritance.rb:61:in `new'
from /var/lib/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/persistence.rb:50:in `create!'
from /var/lib/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/persistence.rb:48:in `block in create!'
from /var/lib/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/persistence.rb:48:in `collect'
from /var/lib/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/persistence.rb:48:in `create!'
from (irb):18:in `block in irb_binding'
from (irb):17:in `each'
from (irb):17
from /var/lib/gems/2.3.0/gems/railties-4.2.6/lib/rails/commands/console.rb:110:in `start'
from /var/lib/gems/2.3.0/gems/railties-4.2.6/lib/rails/commands/console.rb:9:in `start'
from /var/lib/gems/2.3.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:68:in `console'
from /var/lib/gems/2.3.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /var/lib/gems/2.3.0/gems/railties-4.2.6/lib/rails/commands.rb:17:in `<top (required)>'
from /var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
from /var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `block in require'
from /var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency'
from /var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
from /home/crova/Shelter/Dev/Shelter/bin/rails:9:in `<top (required)>'
from /var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:268:in `load'
from /var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:268:in `block in load'
from /var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency'
from /var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:268:in `load'
from /usr/local/lib/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/lib/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
irb(main):020:0> acct_info.each do |x|
irb(main):021:1* Acct.create!
irb(main):022:1> end
(0.1ms) BEGIN
SQL (0.5ms) INSERT INTO `accts` (`created_at`, `updated_at`) VALUES ('2016-06-08 08:12:45', '2016-06-08 08:12:45')
(8.5ms) COMMIT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment