Skip to content

Instantly share code, notes, and snippets.

@dannymcc
Created September 30, 2012 19:47
Show Gist options
  • Save dannymcc/3808272 to your computer and use it in GitHub Desktop.
Save dannymcc/3808272 to your computer and use it in GitHub Desktop.
Calls Mailer
# GET /calls
# GET /calls.json
def index
@calls = Call.order('time DESC').where(:destination => ["123", "456", "789"]).page(params[:page]).per_page(25)
@calls_today = Call.where("created_at >= ?", Time.now.beginning_of_day)
respond_to do |format|
format.html # index.html.erb
format.json { render json: @calls }
end
end
<%= Call.first.time.strftime("%d %b. %Y - %H:%M") %>
<% @calls_today.each do |call| %>
<%= call.time %>
<% end %>
Call Load (0.3ms) SELECT `calls`.* FROM `calls` LIMIT 1
ActionView::Template::Error: undefined method `each' for nil:NilClass
def calls_email(call)
@call = call
mail to: "[email protected]", subject: "Out of Hour Calls"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment