James Englert wrote: > Hey All, > > Two questions. > > 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: do_this({ :a => 'a', :b => 'b' }, { :c => 'c', :d => 'd' }) See if the braces aren't present then it would look like: do_this(:a => 'a', :b => 'b' , :c => 'c', :d => 'd') 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. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---