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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:57:02+00:00 2026-05-26T04:57:02+00:00

Seems like it should be able to look at a simple tutorial or find

  • 0

Seems like it should be able to look at a simple tutorial or find an aswer with a quick google, but I can’t…

codes = PartnerCode.find_by_sql "SELECT * from partner_codes where product = 'SPANMEX' and isused = 'false' limit 1"

I want the column named code, I want just the value. Tried everything what that seems logical. Driving me nuts because everything I find shows an example without referencing the actual values returned

So what is the object returned? Array, hash, ActiveRecord? Thanks in advance.

  • 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-26T04:57:02+00:00Added an answer on May 26, 2026 at 4:57 am

    You need this one

    Partner.where( conditions ).map(&:code)
    

    is shorthand for

    Partner.where( conditions ).map{|p| p.code}
    

    PS

    if you are often run into such case you will like this gem valium by ernie

    it gives you pretty way to get values without instantiating activerecord object like

    Partner.where( conditions ).value_of :code
    

    UPDATED:

    if you need access some attribute and after that update record

    save instance first in some variable:

    instance=Partner.where( conditions ).first
    

    then you may access attributes like instance.code and update some attribute

    instance.update_attribute || instance.update_attributes

    check documentation at api.rubyonrails.org for details

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

Sidebar

Related Questions

This seems like something I should be able to find on Google but I'm
Seems like this should be simple, but powershell is winning another battle with me.
This seems like it should be obvious but I can't figure it out. Suppose
It seems like this should be straight forward but I have not been able
What I'm trying to do seems like it should be simple but is proving
It seems like I should be able to perform bit shift in C/C++ by
Seems like this should be obvious, but how do I send arrow key presses
It seems like this should be straightforward but I'm boggling. I've got my listview
This seems like it should be something very easy to do, but every time
It seems like there should be something shorter than this: private string LoadFromFile(string path)

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.