This project is archived and is in readonly mode.

#5932 ✓stale
jp.blanco

Additional attributes on select don't appear.

Reported by jp.blanco | November 8th, 2010 @ 05:24 PM

In rails 3 if I have a scope and add extra attributes on select, they won't be present in the result.

example:

results=CommunityType.my_scope.select('community_types.*,communities.title as fasd')
results[0].fasd #raises NoMethodError
my_scope implementation...
scope :my_scope, lambda { includes({:communities => :memberships}) & Community.public }

This was working in previous versions of rails.

Comments and changes to this ticket

  • Neeraj Singh

    Neeraj Singh November 10th, 2010 @ 09:57 PM

    • Importance changed from “” to “Low”

    Can you post migration and model info for CommunityType, Community and Membership? I will take a look at this issue.

  • jp.blanco

    jp.blanco November 11th, 2010 @ 02:12 PM

    This is the schema for those models,

     create_table "communities" do |t|
        t.string   "title"
        t.integer  "community_type_id"
      end
    
      create_table "community_types" do |t|
        t.string   "code"
        t.string   "title"
      end
    
    
      create_table "memberships" do |t|
        t.integer  "user_id"
        t.datetime "created_at"
        t.datetime "updated_at"
        t.integer  "community_id"
      end
    

    Thanks in advance

  • Neeraj Singh

    Neeraj Singh November 12th, 2010 @ 06:39 PM

    Can you post model with scope so that I could reproduce the problem. Thanks

  • Santiago Pastorino

    Santiago Pastorino February 12th, 2011 @ 07:18 PM

    • State changed from “new” to “open”

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

  • Santiago Pastorino

    Santiago Pastorino February 12th, 2011 @ 07:18 PM

    • State changed from “open” to “stale”

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages