Re: Strange AR error

2009-02-24 Thread Keenan Brock
Felix,

So glad to be of help.

Microsoft always seems to put square brackets around column and table  
names so you'd see select * from [application].[dbo].[table] in their  
database definition language extracts ('DDL')

So it was worth a try.

You have answered that single quotes work for you - so no need to try  
the square brackets. (It is a database thing not a ruby thing)

Best of Luck

--Keenan

On Feb 24, 2009, at 3:57 PM, Felix Holmgren wrote:

 Hi Keenan,

 Also, the convention is to have underscores rather than camel case.

 This helped! Thank you very much. In the other class, where I let AR  
 create the SELECT and used a the symbol representation of the field  
 name (:firstPeer), AR apparently quoted the name correctly so that  
 postgre understood it. Now I understand why AR always puts quotes  
 around everything! So, in other words, this was not an AR error at  
 all... :)

 Just goes to show that you should always rely on AR as much as  
 possible.

 What happens if you use the ? Notation?
 
 :conditions=[firstPeer = ? or secondPeer = ?,
 @chatter.I'd,@chatter.id]

 Didn't try this, but it seems likely that that would have to be:

 :conditions=['firstPeer' = ? 

 (with extra quotes around firstPeer; can Ruby/Rails handle such  
 quotes-inside-quotes by the way; needs to be escaped?)

 Or use [[firstPeer] = ? or [secondPeer] = ?], ...

 What do these (inner) angular brackets do? Act as quotes?

 /F

 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Heroku group.
To post to this group, send email to heroku@googlegroups.com
To unsubscribe from this group, send email to 
heroku+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/heroku?hl=en
-~--~~~~--~~--~--~---



Strange AR error

2009-02-22 Thread felix

Hi Heroku people!

I started trying out Heroku today and was really impressed and
relieved after struggling many days with a hopeless fcgi deployment
scenario on a big but Rails-unfriendly hosting company. I only wished
I had discovered Heroku earlier and saved myself many late nights of
swearing and desperation.

But... Although everything seemed to work 95% perfectly on the first
try, I'm getting some bizarre errors, and I'm hoping there are people
out there with some suggestions, because I'm pretty perplexed.

So this is what I get in my log:

ActiveRecord::StatementInvalid (PGError: ERROR:  column firstpeer
does not exist
LINE 1: SELECT * FROM switches WHERE (firstPeer = 15 OR
secondPeer...
^
: SELECT * FROM switches WHERE (firstPeer = 15 OR secondPeer =
15) ):

AR is complaining that there is no column firstpeer. I'm not sure if
the fact that it is all lower case has any significance. The actual
column is named firstPeer, as visible in the SQL log lines.

The source line that gives rise to this error is located in
Application.rb, and looks like this:

switches = Switch.all(:conditions = ['firstPeer = :myID OR secondPeer
= :myID' , {:myID = @chatter.id}])

Nevertheless, the following line in another script (in initializers)
does get executed w/o problems:

switch = Switch.create(:firstPeer = chatter.id , :secondPeer =
peer.id, :distance = dist)

and executing heroku console Switch.all, I get: [#Switch id: 1,
firstPeer: 1, secondPeer: 2, created_at: 2009-02-22 17:11:26,
updated_at: 2009-02-22 17:11:26, distance: 1235986.83901638,  etc

Being rather new to Rails and completely new to Heroku, I have
absolutely no idea what might be going on.

I develop using MySQL locally, and used that for my former deployment
(which sucked but never threw this error at me) but mysql/posrgre
issues could hardly have anything to do with this.

My app forks off processes using the Spawn plugin, some running for a
few secs, and some for as long as the main thread (at least that's the
intention). All of this *seems* to work fine, although the error I've
just described makes it hard to check this thoroughly. Could spawning
processes (basically the same as a unix fork) cause any troubles?

I would be *very* grateful for any (quick) comments and suggestions,
as I'm really eager to get my app to work on Heroku.

/F
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Heroku group.
To post to this group, send email to heroku@googlegroups.com
To unsubscribe from this group, send email to 
heroku+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/heroku?hl=en
-~--~~~~--~~--~--~---