Skip to content

Instantly share code, notes, and snippets.

@MikeSilvis
MikeSilvis / gist:2632517
Created May 8, 2012 04:12
Ticket Update
class TicketsController < ApplicationController
def index
@create_ticket = Ticket.new
@new_tickets = Ticket.where("state='new'");
@current_tickets = Ticket.where("state='current'");
@completed_tickets = Ticket.where("state='completed'");
end
def show
@MikeSilvis
MikeSilvis / Schema.rb
Created May 16, 2012 19:58
Squeel Joins
# I have the following two tables and I want to find both the growls and the regrowls sorted by the created_at for growls BUT also the created_at for regrowls.
create_table "regrowls", :force => true do |t|
t.integer "user_id"
t.integer "growl_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "growls", :force => true do |t|
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
BLUE="\[\033[0;36m\]"
PINK="\[\033[0;35m\]"
WHITE="\[\033[1;37m\]"
BLACK="\[\033[0;30m\]"
OFF="\[\033[0m\]"
@MikeSilvis
MikeSilvis / gist:2839845
Created May 31, 2012 00:33
index.js.coffee
class App extends Spine.Controller
constructor: ->
super
new Spine.SubStack
Spine.Route.setup()
@append(@rooms = new App.Rooms)
@append(@messages = new App.Messages)
@MikeSilvis
MikeSilvis / redis.rb
Created July 5, 2012 16:56
resque.rake
require 'resque'
if Rails.env.production?
redis_url = ENV["REDISTOGO_URL"]
uri = URI.parse(redis_url)
REDIS = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
else
REDIS = Redis.new
end
Resque.redis = REDIS
Resque.after_fork = Proc.new { ActiveRecord::Base.establish_connection }
require 'resque'
if Rails.env.production?
redis_url = ENV["REDISTOGO_URL"]
uri = URI.parse(redis_url)
REDIS = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
else
REDIS = Redis.new
end
Resque.redis = REDIS
Resque.after_fork = Proc.new { ActiveRecord::Base.establish_connection }
require 'resque/tasks'
ENV["QUEUE"] = "*"
task "resque:setup" => :environment
task "jobs:work" => "resque:work"
def create
score1 = Score.new(:points => params[:score1], :player_id => params[:player1_id])
score2 = Score.new(:points => params[:score2], :player_id => params[:player2_id])
game = Game.new(params[:game], scores: [score1, score2])
redirect_to games_path, notice: "Game results recorded!" if game.save
end
heroku ps:scale worker=1
heroku ps:scale worker=1