Hi Kathleen and welcome, The Account.find_by_code must be returning a nil, hence the complaint about using .first method on it.
But I'm wondering if you should write it as: @account = Account.find_by_code(row[3]).first if row[3] The find_by_code IIUC does the conditional for you, hence the strange resulting SQL statement when specifying what Rails probably considers an additional conditional. Good luck, sorry for the delay! Kevin [EMAIL PROTECTED] wrote: > Normally, I would post this to the Rails forum but Heroku is my new > love and I thought maybe I'd meet some people there...so here goes. > I am trying to perform a FIND method against a lookup table and am > being hexed? > I've written a few large Rails applications and seem to be going round > and round with this, and thought I'd see about some help. > > I am reading records into a migration using FasterCSV and have used > this successfully many times. This time, I'm trying to exercise this > logic; > > I read the ASSET .csv record with the ambition of converting the > 'asset.code' incoming field into the unique id ( account_id) of the > ACCOUNT lookup table that will become asset.account_id. > I am certain that the ACCOUNT table is healthy and has a account.code > string = 1002. > > Here I read the lookup table; > @account = Account.find_by_code(:conditions => ['code = ?', > row[3]]).first unless row[3].nil? > > this is the development log line that shows what happened; > > SELECT * FROM `accounts` WHERE (`accounts`.`code` IS NULL) AND (code = > '1002') LIMIT 1 > I am getting the error message that .first method can't be performed > against a NULL object. Also, I have no idea why MySQL is performing a > NULL AND (my request) in the resulting statement. > I've got to do a lot of these 'lookups' in my conversion and must > transcend this problem. > I am grateful for any help. > Kathleen > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Heroku" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/heroku?hl=en -~----------~----~----~----~------~----~------~--~---
