I got a table named users, and I’m doing
array = User.where("username=?", username)
to get the user for a specific username.
My minor gripe is that this returns an array, and I have to do array[0] but there should always be just 1 user returned.
Is there anyway, syntactically to specify that I expect just 1 record, and it shouldn’t be an array returned, just the user?
You can limit it to one result:
However, you might just want to use the dynamic
find_by_method: