Skip to content

Instantly share code, notes, and snippets.

class AlertPresenter < CachingPresenter
presents :alert, :accepts => [:action, :current_user]
attr_reader :action
def acknowledged_by_user?
if attempt = @alert.alert_attempts.find_by_user_id(@current_user)
attempt.acknowledged?
end
end
<% form_for @alert, :url => cancel_alert_path(@alert.original_alert.nil? ? @alert : @alert.original_alert) do |form| %>
<div id="edit">
<%= render form %>
<%= form.submit "Preview Message" %>
</div>
<div id="preview">
<%= render @alert %>
<%= link_to 'Edit', '#edit', :class => 'edit' %>
def create
@alert = current_user.alerts.build params[:alert]
if params[:send]
@alert.save
@alert.deliver
flash[:notice] = "Successfully sent the alert"
redirect_to logs_path
else
render :template => "alerts/preview"
end