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

  • SEARCH
  • Home
  • 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 6553825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:37:38+00:00 2026-05-25T12:37:38+00:00

I have this code… User.find :all, :select => users.id, departments.name, users.username, response_sets.id AS ‘response_set_id’,

  • 0

I have this code…

User.find :all, 
          :select => "users.id, departments.name, users.username, response_sets.id AS 'response_set_id', response_sets.survey_id, COUNT(responses.id) AS 'answers', response_sets.completed_at", 
          :joins => "LEFT JOIN departments ON users.department_id = departments.id LEFT JOIN versions ON departments.version_id = versions.id LEFT JOIN response_sets ON users.id = response_sets.user_id AND versions.survey_id = response_sets.survey_id LEFT JOIN responses ON response_sets.id = responses.response_set_id AND responses.answer_id IS NOT NULL", 
          :conditions => {:id => 4}, 
          :group => "users.id"

And all it’s returning is this [#<User id: 4, username: "3333">] should there be more? because of my :select?? should I have use :include instead of :joins..still learning..newbie here! xP

  • 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-25T12:37:39+00:00Added an answer on May 25, 2026 at 12:37 pm

    There actually is more in all the instances but what you see is the result of a call to the method inspect and that will only show the content of the actual columns from the User model. But if you try to call the other values returned by your statement you should be able to see the result. For example:

    @users.first.response_set_id # => will return the value from response_sets.id
    @users.first.answers         # => will return the value from COUNT(responses.id)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: <label for=subject accesskey=S>Subject</label> <select name=subject type=text id=subject> <option value=a dog>Dog</option>
I have this code : <ul> <li>Start</li> <li>Hello my</li> <li>name is</li> <li>Marco</li> </ul> and
I have this code var contacts = dr.mktDoctorContacts .GroupBy(x => x.ContactType) .Select(zb => new
I have this code in my routes.db file: resources :users do member do get
I have this code which getting html code of page and than replace all
i have this code preg_match_all('%(?:youtube\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^&?/ ]{11})%i', $asd, $match); to find youtube key of urls
I have this code, but this line has some problem. var dataString = 'name='+name&'id='+id;
I have this code here : <select id=test> <option value=1>test1</option> <option value=2 selected=selected>test2</option> <option
I have this code in jQuery, that I want to reimplement with the prototype
I have this code: chars = #some list try: indx = chars.index(chars) except ValueError:

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.