Firstly, what is the difference between create and create!
create returns true if successful, false otherwise. create! throws an
exception if the operation fails for any reason.
What are the differences between these two calls?
a) SomeModel.create!{ :property_a => ‘value’, :property_b => ‘value 2’
}
b) SomeModel.create!({ :property_a => ‘value’, :property_b => ‘value
2’ })
Nothing. The {} indicating the hash is optional if it’s obvious to the
Ruby interpreter. If you were to have two hash arguments you need to
separate them properly so the interpreter understand what to do:
Which is probably not what you want if you intended to send two hashes
to the method. In the second case there is only one hash send and the
second argument would not be set.
It might do you some good to go back and brush up your basic Ruby
skillz.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.