ActiveRecord create without_protection - wrong number of arguments (2 for 1)

I cannot understand what is wrong with this create statement in my User model:

User.create({first_name: "Alan",....}, :without_protection => true)

Gives me a stack trace:

ArgumentError: wrong number of arguments (2 for 1)
from /Users/alanheppenstall/.rvm/gems/ruby-1.9.3-p362/gems/activerecord-4.0.0/lib/active_record/persistence.rb:32:in `create'
from (irb):56
from /Users/alanheppenstall/.rvm/gems/ruby-1.9.3-p362/gems/railties-4.0.0/lib/rails/commands/console.rb:90:in `start'
from /Users/alanheppenstall/.rvm/gems/ruby-1.9.3-p362/gems/railties-4.0.0/lib/rails/commands/console.rb:9:in `start'
from /Users/alanheppenstall/.rvm/gems/ruby-1.9.3-p362/gems/railties-4.0.0/lib/rails/commands.rb:64:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'

My syntax matches: http://apidock.com/rails/ActiveRecord/Base/create/class/

I am using a device with this model - maybe this is a problem? I could not find anywhere where they override initialize ().

Thank!

+3
source share
2 answers
+5

4

User.create({id: 101, first_name: "Alan",....})

Rails id = 101

, - id 101

ActiveRecord:: RecordNotUnique: PG:: UniqueViolation: : "users_pkey"

0

All Articles