Skip to content

Instantly share code, notes, and snippets.

@cdesch
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdesch/11320595 to your computer and use it in GitHub Desktop.
Save cdesch/11320595 to your computer and use it in GitHub Desktop.
def index
@events = Event.where("published == ? AND event_date >= ?", true, DateTime.now.beginning_of_day).order('event_date ASC').limit(6)
end
MyDB=# \d+ events
Table "public.events"
Column | Type | Modifiers | Storage | Description
-------------------+-----------------------------+-----------------------------------------------------+----------+-------------
id | integer | not null default nextval('events_id_seq'::regclass) | plain |
title | character varying(255) | | extended |
description | character varying(255) | | extended |
event_date | timestamp without time zone | | plain |
published | boolean | | plain |
created_at | timestamp without time zone | | plain |
updated_at | timestamp without time zone | | plain |
image | character varying(255) | | extended |
short_description | character varying(255) | | extended |
Indexes:
"events_pkey" PRIMARY KEY, btree (id)
Has OIDs: no
I, [2014-04-25T21:25:04.517356 #5204] INFO -- : Rendered home_pages/_event_feed.html.erb (10.1ms)
I, [2014-04-25T21:25:04.518347 #5204] INFO -- : Rendered home_pages/index.html.erb within layouts/application (64.7ms)
I, [2014-04-25T21:25:04.518627 #5204] INFO -- : Completed 500 Internal Server Error in 136ms
F, [2014-04-25T21:25:04.529371 #5204] FATAL -- :
ActionView::Template::Error (PG::UndefinedFunction: ERROR: operator does not exist: boolean == unknown
LINE 1: ...1 AS count_column FROM "events" WHERE (published == 't' AND...
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
: SELECT COUNT(count_column) FROM (SELECT 1 AS count_column FROM "events" WHERE (published == 't' AND event_date >= '2014-04-25 00:00:00.000000') LIMIT 6) subquery_for_count):
17: <!-- Article -->
18: <article>
19:
20: <% if @events.empty? %>
21: <div class="centralized">
22: <h3>No Up Comming Events</h3>
23: </div>
app/views/home_pages/_event_feed.html.erb:20:in `_app_views_home_pages__event_feed_html_erb__3889985363541854763_61846520'
app/views/home_pages/index.html.erb:14:in `_app_views_home_pages_index_html_erb___1062197754194261604_60313380'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment