Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3353728
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:11:11+00:00 2026-05-18T02:11:11+00:00

I have started learning Ruby on Rails and I have been stuck at something

  • 0

I have started learning Ruby on Rails and I have been stuck at something and need you help. To learn Rails, I am building an app for creating, filling and reporting surveys.

My model is like – Each Survey has many Questions and each Survey has many Responses. Each Response has many Answers.

On my reports page controller, I am doing something like –

def index
    #@survey = Survey.find(params[:survey_id])
    @user_responses = Response.where("survey_id = ?", params[:survey_id])
end

and on the view –

<% @user_responses.each do |response| %>
 Responder Name - <%= response.responder_name %><br/>
 <% response.answers do |answer|%>
Question Id - <%= answerx.question_id %>
Answer - <%= answer.answer_text %>
<%  end%>
<% end %>

I can see the query being executed on the backend (due to the loop on the view), e.g.

[1m[36mResponse Load (0.3ms)[0m  [1mSELECT "responses".* FROM "responses" WHERE (survey_id = '14')[0m
[1m[35mAnswer Load (0.3ms)[0m  SELECT "answers".* FROM "answers" WHERE ("answers".response_id = 14)
[1m[36mAnswer Load (0.2ms)[0m  [1mSELECT "answers".* FROM "answers" WHERE ("answers".response_id = 15)

But on the view I am not able to see the “answer_text”/”question_id”. I can only see “responder_name”

This has something to do with queries being executed from the view ?

Please help me.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T02:11:12+00:00Added an answer on May 18, 2026 at 2:11 am

    I think you want:

    <% response.answers.each do |answer| %>
    

    With an each.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have started learning ruby and i have been looking at ruby on rails.Is
I have just started learning ruby on rails. I have a doubt wrt routing.
I have just started learning Ruby on Rails. I happened to look for prevention
I have just started out learning rails and ruby, so please bear with me
I've been a web developer for some time now, and have recently started learning
I have been interested in learning Rails for some time now and feel now
I have started learning Ruby for the past 2,3 weeks and I have come
I started learning Ruby on Rails and found myself confounded by the syntax, so
I've only just started learning ruby on rails and I would like to create
I have started learning Ruby, and I have read a couple of tutorials and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.