Reputation: 970
I have created some fixtures without ID in my rails 4.2 application. Since I relay on the ids in the url, I need a way to retrieve the autogenerated IDs in the database in the minitest files.
Remark: I am not using explicit ids in the fixtures. I am using this format:
student:
name: Reginald_the_Pirate
age: 14
In my controller I want something like:
get: :student, student_id: "?"
Upvotes: 1
Views: 748
Reputation: 970
this is the response. It is easier than what expected:
students(:Reginald_the_Pirate).id
Upvotes: 0
Reputation: 865
student = students(:student)
get :student, :student_id => student.id
Upvotes: 2