Skip to content

Instantly share code, notes, and snippets.

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
<% 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' %>
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
Feature: Acknowledging an alert
In order to report that I read an alerts
As a user
I can acknowledge an alert
Background:
Given the following users exist:
| Martin Fowler | martin@example.com | Health Official | Dallas County |
And the role "Health Official" is an alerter
class HashRowColumn
include MongoMapper::Document
key :row, String
key :column, Hash
key :column_ids, Array
def self.[](r = nil)
return HashRowColumns if(r.nil?)
hr = HashRowColumn.find_by_row(r)
if(hr)
>> HashRowColumn.all
=> [#<HashRowColumn column: {}, row: "3", _id: 4b95d9ca24b0441937000001, column_ids: []>, #<HashRowColumn column: {}, row: nil, _id: 4b95de0324b0441be6000001, column_ids: []>, #<HashRowColumn column: {"2"=>"This", "3"=>"Test", "4"=>"Test", "5"=>"Me"}, row: "2", _id: 4b95d55a24b04415aa000001, column_ids: ["2", "3", "4", "5"]>, #<HashRowColumn column: {"2"=>"Blue"}, row: "1", _id: 4b95c91d24b0440ceb000001, column_ids: ["2"]>, #<HashRowColumn column: {"22"=>"You", "2"=>"Me Too!"}, row: "16", _id: 4b95c96224b0440ceb000002, column_ids: ["2"]>]
>> HashRowColumn["1"]["17"] = "My Test"
=> "My Test"
>> HashRowColumn.all
=> [#<HashRowColumn column: {}, row: "3", _id: 4b95d9ca24b0441937000001, column_ids: []>, #<HashRowColumn column: {}, row: nil, _id: 4b95de0324b0441be6000001, column_ids: []>, #<HashRowColumn column: {"2"=>"This", "3"=>"Test", "4"=>"Test", "5"=>"Me"}, row: "2", _id: 4b95d55a24b04415aa000001, column_ids: ["2", "3", "4", "5"]>, #<HashRowColumn column: {"17"=>"My Test", "2"=>"Blue"},
@Dishwasha
Dishwasha / gist:901736
Created April 4, 2011 14:33
cloud-setup-management issue
[root@cloud CloudStack-2.2.3-1-fedora14-oss]# cloud-setup-management
Welcome to the CloudStack Management setup
cloud.texashan.org
The hostname of this machine is properly set up
Executing the following reconfiguration script:
rm /files/etc/sudoers/Defaults[1]
save
sudoers reconfiguration failed.
[root@cloud ~]# cobbler repo report
Name : FC15-x86_64
Arch : x86_64
Breed : yum
Comment :
Createrepo Flags : <<inherit>>
Environment Variables : {}
Keep Updated : True
Mirror : http://mirror.anl.gov/pub/fedora/linux/releases/15/Everything/x86_64/os/
Mirror locally : True
@Dishwasha
Dishwasha / gist:1602521
Created January 12, 2012 19:27
Add jasmine to default rake task
require 'rspec/core'
require 'rspec/core/rake_task'
require 'jasmine-headless-webkit'
# Run Jasmine headless via webkit
Jasmine::Headless::Task.new('jasmine:headless')
# Add to default rake task
if default = Rake.application.instance_variable_get('@tasks')['default']
default.prerequisites.unshift('jasmine:headless')
@Dishwasha
Dishwasha / jquery.wijmo.wijpiechart.js
Created March 8, 2012 18:03
Wijmo pie chart labels fix
/*globals Raphael,jQuery, window*/
/*
*
* Wijmo Library 2.0.0
* http://wijmo.com/
*
* Copyright(c) ComponentOne, LLC. All rights reserved.
*
* Dual licensed under the Wijmo Commercial or GNU GPL Version 3 licenses.
* licensing@wijmo.com