In Ruby what is the meaning of colon after identifier in a Hash?

前端 未结 3 1842
暗喜
暗喜 2021-02-05 08:00

I\'m learning about Factory Girl and I saw this code:

factory :post do
  association :author, factory: :user, last_name: \"Writely\"
end

why do

3条回答
  •  礼貌的吻别
    2021-02-05 08:33

    Ruby 1.8 syntax:

    :factory => :user
    

    Ruby 1.9 syntax:

    factory: :user
    

    Note that the Ruby 1.8 syntax works in 1.9 also.

提交回复
热议问题