I am trying to display the next three future events from my database but nothing below the code have been shown. I can not see what I have done.
This event is the controller:
Class Events Controller & lt; ApplicationController def Show @Event = Event.where (: slug = & gt; Parameter [: Slug]). First @ futures_events = event. Where ('end_date & gt;?', Datedot) .order ('end_date ASC') Limit (3) Normal: Firstly.Gate_blog General.First.GT_Titvitter if @Event. Anil? @event = Event.first end @days = [{speakers: @ event.sessions.day1_speakers, workshops: @ event.sessions.day1_workshops}, {speakers: @ event.sessions.day2_speakers, workshops: @ event.sessions.day2_workshops} ] End End And this is the event view:
& lt;% @ future_events.first (3) .each do | E & Gt%; & Lt; Div class = "charcoal column column" & gt; & Lt; H3 & gt; & Lt;% = e.title% & gt; & Lt; / H3 & gt; & Lt; P & gt; & Lt;% = e.start_date.strftime ("% e% B% Y")%>, & lt;% = E.V.title% & gt; & Lt; / P & gt; & Lt; P & gt; & Lt;% = e.event_description% & gt; & Lt; / P & gt; & Lt; / Div & gt; & Lt;% end% & gt;
You should only compose your query to return events that you need :
Event. Where ('end_date & gt;?, Date.today) .order (' end_date ASC '). Border (3) Beyond that, I can not see why nothing is displayed, can you post your entire controlling method?
Update: This is the equivalent query for Mongol:
event.where (: end_date.gt = & Gt; DateTod) .sort (: end_date = & gt; 1) .limit (3)
No comments:
Post a Comment