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.
You need this one
is shorthand for
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
UPDATED:
if you need access some attribute and after that update record
save instance first in some variable:
then you may access attributes like
instance.codeand update some attributeinstance.update_attribute || instance.update_attributescheck documentation at api.rubyonrails.org for details