I’m learning about Factory Girl and I saw this code:
factory :post do
association :author, factory: :user, last_name: "Writely"
end
why do factory and last_name have a colon at their end?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The colon in this context denotes a literal Hash.
factoryis theHashkey,:useris the value.The alternative syntax is
:factory => :user. They mean the same thing.