I am writing some code in Ruby on Rails to Create an object.
I am using Ruby 2.0 and Rails 4.0.3 in my Application.
I have a Model called:
class GroupUsers < ActiveRecord::Base belongs_to :users belongs_to :group
This is basically a ManyToMany mapping between Users and Groups. So, today I was creating an object for this Model.
But I found out I could follow two syntax for this, as follows
GroupUsers.create( :user => user, :group => group )
GroupUsers.create( user: user, group: group )
Basically since this is related to creating a Hash so it must be a question of the best practice in Ruby.
Which syntax should be preferred ?