简体   繁体   中英

RAils 3.1 Why does this query work in development but not in production?

note: finishDate is a field in Events table

This query works fine in development

def reminders
  @events = @user.events.find(:all, :conditions=> ['finishDate >= ?', Time.now])
end

but throws this error in production

ActiveRecord::StatementInvalid (PG::Error: ERROR:  column "finishdate" does not exist
LINE 1: ...vent_id" WHERE "events_users"."user_id" = 13 AND (finishDate...
                                                             ^

heroko console

>> Event.last.finishDate
=> Tue, 10 Apr 2012 19:05:00 UTC +00:00

What am I missing? Thanks in advance!

It seems that your table does not have such a column as "finishDate." Are you sure that both tables (if there are two) are identical? Maybe you made some changes manually and have not been introduced to an array of production.

Besides, a lot more helpful would be a full SQL query that is displayed next to the summary of the selected error.

I renamed the table column from

finishDate

to

finish_date

and worked perfectly!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM