How do I select a single entity from a relation? I’m using Rails 4.2.3. I have the below query, which joins on another table, but I only wish to delete one of the objects (the object of type “UserMyObjectTimeMatch”) …
user_my_object_time_match = UserMyObjectTimeMatch.joins(:my_object_time)
.select(:user_my_object_time_match)
.where("race_time_id = ?", linked_my_object.race_times[0].id)
if !user_my_object_time_match.nil?
user_my_object_time_match.destroy
end
Unfortunately, when the “user_my_object_time_match.destroy” line is called, a “wrong number of arguments (given 0, expected 1)” error is resulting and I believe it is because the object I’m selecting is not of the right type. How do I properly select an object from a relation?