When I get my @variables with:
@variables = Variable.all
I can do
@variables.each do |variable|
just fine, but when I get it with the find_by, like so:
@variables = Variable.find_by_user_id(user.id)
I get an each method not found error!
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 find_by_field methods return a single record, which you can’t iterate over.
What you want is
or
or (assuming you have an association set up properly)