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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:40:24+00:00 2026-05-28T19:40:24+00:00

I have a Position model for which I have a scope defined: scope :default,

  • 0

I have a Position model for which I have a scope defined:

scope :default, where('is_default = ?', 1)

Idea being that I want to know which is the default position. I can do something like: @profile.positions.default and this returns an activerecord relation and the default position record. The issue is that now that I have the default record, I need to access other attributes of Positions such as title..

@profile.positions.default.title 

but the above returns an error: NoMethodError: undefined method `title’ for #

Any clues? 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-28T19:40:25+00:00Added an answer on May 28, 2026 at 7:40 pm

    A scope turns a collection of objects, not a single object, so you’re trying to call title on an array of ActiveRecord results.

    You probably want something like this:

    @profile.positions.default.first.title
    

    Or if you always want just one record, you may switch from a scope to a class method:

    def self.default
      where('is_default = ?', 1).first
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an IE6 absolute position div that I want to be full screen
I have a model that has a bone which has a translated offset from
I have a 3D model which has position, uv, normal, indices info. I need
Have a matrix report now that has Position, Hours and Wages for a location
I have a problem about div position relative alignment. I want the second div
i have a container div which is position:relative and the squares are position:absolute because
I have a small algorithm which replaces the position of characters in a String:
I have an Panel control that I need to maintain position across postbacks. I
I have an odd situation in which I need to modify the position of
I have a .NET Windows Service which spawns a thread that basically just acts

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.