Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion find_by_sql - ActiveRecord - Help please.
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jeff Lockyer  
View profile  
 More options Nov 7 2012, 3:08 pm
From: Jeff Lockyer <li...@ruby-forum.com>
Date: Wed, 07 Nov 2012 21:07:16 +0100
Local: Wed, Nov 7 2012 3:07 pm
Subject: find_by_sql - ActiveRecord - Help please.
I am new to the language and trying to add a couple of simple tests on
user input, followed by a DB query, then using the returned values
(where the problem lies)

I first run a find_by_sql similar to this

@my_names = modelname.find_by_sql

I then check to see if NO returns via

if @my_names.size == 0

==================

My question is, how do I access the values that are now in the array. I
seem to be able to set session variables by way of

session[:whatever] = @my_names[0].column_name
etc..

but am unable to perform a if construct that looks like

if @my_names[0].column_name == "TEST VALUE"

I keep getting an undefined method error when I try to run the code.
Thanks very much in advance for any assistance with this.

--
Posted via http://www.ruby-forum.com/.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.