Two questions are being asked here.
First question: method deprecation
Changes were made in this commit.
The create
method was removed from ActiveRecord::Base
and inserted into a separate module called ActiveRecord::Persistence
.
Regarding what APIDock told you... the method was "deprecated or moved." If you look halfway down the list of suggestions, you will see ActiveRecord::Persistence#create
. This is where the method moved to.
Note that ActiveRecord::Persistence#create
is used internally. When calling create
on an ActiveRecord model (not object) in your application code, you are invoking ActiveRecord::Relation#create
.
ActiveResource::Base#create
was introduced in Rails 2.0 and is unrelated to ActiveRecord.
Second question: hash as arguments
Examining the source for ActiveRecord::Relation#create
shows the following:
# File activerecord/lib/active_record/relation.rb, line 85
def create(*args, &block)
scoping { @klass.create(*args, &block) }
end
See the splat argument *args
? This tells Ruby to pass all remaining arguments into args
, no matter how many there are. Ruby/Rails' ducktyping magic sees a bunch of key-value pairs and assumes it to be a hash.
Rails is a bit loose with requiring curly brackets for hashes in arguments, just as it is loose about wrapping all arguments in parentheses. Generally, Rails will infer a hash when you pass in a series of key-value pairs. Sometimes this causes trouble when passing in multiple hashes, like in a complex form_for
method.
If you have erratic behavior with curly brackets absent, insert them. Clearly defining hashes will allow you to ensure proper behavior.
Read more about Ruby splats here.