This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# KeepAlive: Whether or not to allow persistent connections (more than | |
# one request per connection). Set to "Off" to deactivate. | |
# | |
KeepAlive On | |
# | |
# MaxKeepAliveRequests: The maximum number of requests to allow | |
# during a persistent connection. Set to 0 to allow an unlimited amount. | |
# We recommend you leave this number high, for maximum performance. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Works fine! | |
class User < ActiveRecord::Base | |
has_many :issued_tickets, :class_name => 'Ticket', :foreign_key => :issuer_id | |
end | |
# Failboat! | |
class User < ActiveRecord::Base | |
has_many :issued_tickets, :class_name => Ticket, :foreign_key => :issuer_id | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
has_attached_file :avatar, | |
:styles => { :medium => "200x600>", :thumb => "50x50", :small => "32x32" }, | |
:default_url => "/images/missing/avatars/:style.png" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() | |
{ | |
$('.polaroids .post').click(function() | |
{ | |
window.location = $(this).children('a:first').attr('href'); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'htmlentities' | |
class String | |
def slugify | |
self.gsub(/[^a-z0-9]+/i, '-').chomp('-') | |
end | |
def decode | |
HTMLEntities.new.decode(self) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class StatusReminder | |
class << self | |
def send_reminders | |
offset = 0 | |
jump = 100 | |
while( users = User.eligible_for_status_reminder(offset, jump) && !users.empty? ) | |
users.each do |user| | |
logger.info("StatusReminder: Reminding #{user}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe MakesController do | |
fixtures :users | |
integrate_views | |
describe "index should be visible to" do | |
# this is a macro that just pumps out three tests: log in anonymous, log in as a user, log in as an admin | |
it_should_behave_like "check all users" | |
before do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If you ever needed an array of all models in your Rails app (+ Session) | |
Dir.glob("app/models/*.rb").each{|r| require r}; subclasses_of(ActiveRecord::Base).map{|c| c.class_name} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Given /I am on the new make page/ do | |
visits new_make_url | |
end | |
Then /a new make called "(\w+)" should be created/ do |name| | |
Make.exists?(:name => name).should be_true | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Given /I am on the edit make page for "(\w+)"/ do |name| | |
@id = Make.find_by_name(name).id | |
visits edit_make_url(@id) | |
end | |
When /its name should be updated to "(\w+)"/ do |name| | |
Make.find(@id).name.should == name | |
end |