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 4577694
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T20:22:54+00:00 2026-05-21T20:22:54+00:00

Coming from Rails 2 to Rails 3 I’ve never worked so hard to understand

  • 0

Coming from Rails 2 to Rails 3 I’ve never worked so hard to understand something (side editorial).

Anyway, In a Rails 3 app i have the following models…

User:

has_many :answers

Answer:

belongs_to :user
belongs_to :question
scope :user_answers, where (:user_id => current_user.id)

Question:

has_many :answers
scope :qs_w_user_ans, joins(:questions) & (:user_answers)

The current error i am getting is “undefined method `includes_values’ for :user_answers:Symbol”

There is a Question id and a User id. Each answer has question_id and user_id.

I need the questions with a user’s answers linked appropriately via the ids. Can you show me where my models are wrong?

Thank you.

  • 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-21T20:22:54+00:00Added an answer on May 21, 2026 at 8:22 pm

    The & operator (which I believe is recently deprecated) is an alias for merge, which allows you to essentially merge scopes. :user_answers isn’t a scope, so you can’t use this method.

    As Dinatih pointed out, you can call joins multiple times. In this case, creating different scopes for each join won’t buy you much, so his method suits your case.

    More info on scopes: http://archives.edgerails.info/articles/what-s-new-in-edge-rails/2010/02/23/the-skinny-on-scopes-formerly-named-scope/index.html

    Update

    Sorry for my misunderstanding. :user_answers is a scope, but you’re not calling it correctly in this case. You want the following:

    scope :qs_w_user_ans, joins(:questions) & Answer.user_answers
    

    When merging scopes, you call the merged scopes like class methods.

    In the article I linked, the scope :published on Post is merged with the scope :published on User:

    scope :published, lambda {
      joins(:posts).group("users.id") & Post.published
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am coming from the world of PHP and am learning Ruby/Rails. I have
I'm having problems in Firefox with 302 redirects coming from my Rails app. Right
I have two complex rails (AR) queries coming from two different methods that I
I'm coming from a Rails programming experience. I'm coding an app in Python on
I have an RHTML view in Rails, where the output is coming from my
Coming from java/groovy/grails we are currently moving to rails. We have been having an
I am coming from a Spring/hibernate background. I have noticed that Rails has no
I have a rails app that loads lots of data from some java services.
I'm coming from the .NET world, and I'm trying to figure out the Rails
I am working on a streaming download (CSV) from Rails 3.2 and am coming

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.