2

I'm using ruby 1.9.2 and rails 3 with a postgresql 8.4 database.

I have the following piece of rails code.

@playersonline = Member.find(:all, :conditions => ["loggedIn = ?", true] )

And I get the following error when the line is encountered:

PGError: ERROR:  column "loggedin" does not exist

Looking at the query it generates it shows the following:

SELECT     "members".* FROM       "members"  WHERE     (loggedIn = 't')

The loggedIn column does exist in my table, and it has a boolean data type.

Another thing that is odd, when I try to query just the loggedIn column via a sql browser I get the same error? i.e. select loggedIn from members

Thanks

1
  • It seems like your problem is in the database, not rails. Can it be a column name case issue? Commented Mar 11, 2011 at 15:04

1 Answer 1

4

Postgres is case-sensitive by default so loggedIn isn't the same as loggedin. Although you can override it, Rails convention is that variable name-parts are separates by an underscore.

I wouldn't recommend re-inventing the wheel. Go in and change the columnn name (and any other columns that follow your notation) you might have to logged_in. This will prevent you from encountering any more strange errors.

Sign up to request clarification or add additional context in comments.

1 Comment

Perfect, all columns renamed and working now. Relatively new to rails so forgot about its naming conventions. Thanks Chuck

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.