Skip to content

Instantly share code, notes, and snippets.

View DCarper's full-sized avatar

Dan Carper DCarper

View GitHub Profile
(rdb:1) old = Chronic.parse('yesterday at 5am')
(rdb:1) Comment.all(:conditions => ['created_at > ?', old]).include? Comment.last
=> true
(rdb:1) Comment.last.created_at > old
=> false
class Bracket < ActiveRecord::Base
has_many :guesses
has_many :memberships
has_many :comments, :through => :memberships
# Class Guess < BracketInfo
named_scope :recently_updated, :include => [:comments, :guesses], :conditions => ['bracket_infos.created_at > ? OR comments.created_at > ?', Chronic.parse("Yesterday at 5 am"), Chronic.parse("Yesterday at 5 am")]
# Good # Bracket.recently_updated => [...]
class Bracket < ActiveRecord::Base
has_many :memberships
has_many :comments, :through => :memberships
has_many :guesses
end
class BracketsController < ApplicationController
def index
yar!
end
end
respond_to do |wants|
wants.json do
if @fold.save
redirect_to :edit
else
render :json => false
end
end
end
Missing template partial_path in view path
@DCarper
DCarper / gem error.sh
Created May 12, 2011 22:57
whenever error
Using whenever (0.6.7) from git://github.com/DCarper/whenever.git (at master) NOTE: Gem::Specification#default_executable= is deprecated with no replacement. It will be removed on or after 2011-10-01.
Gem::Specification#default_executable= called from /Users/Dan/.rvm/gems/ruby-1.8.7-p334@global/specifications/bundler-1.0.11.gemspec:10.
NOTE: Gem::Specification#default_executable= is deprecated with no replacement. It will be removed on or after 2011-10-01.
Gem::Specification#default_executable= called from /Users/Dan/.rvm/gems/ruby-1.8.7-p334@global/specifications/rake-0.8.7.gemspec:10.
/Users/Dan/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/installer.rb:357:in `initialize': No such file or directory - /Users/Dan/.rvm/gems/ruby-1.8.7-p334@empty/bundler/gems/gems/whenever-0.6.7/bin/whenever (Errno::ENOENT)
from /Users/Dan/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/installer.rb:357:in `open'
from /Users/Dan/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems/installer.r
@DCarper
DCarper / t.js
Created May 9, 2011 14:58
what i'd like to do
if ( confirmed() )
{ do some stuff }
- owner_only do
= link_to "My Control Panel", edit_bracket_path(@bracket), :title => 'Admin'
def prefix_template
def self.default_template_name(action_name = self.action_name)
if action_name
action_name = action_name.to_s
if action_name.include?('/') && template_path_includes_controller?(action_name)
action_name = strip_out_controller(action_name)
end
end
"admin/#{self.controller_path}/#{action_name}"
end