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
# PaperTrail's version class (existing code omitted for clarity). | |
class Version < ActiveRecord::Base | |
before_update :before_update_hook | |
after_update :after_update_hook | |
def before_update_hook | |
end | |
def after_update_hook | |
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
# Put this file in your config/initializers directory and behold a tastier auto_link! | |
module ActionView | |
module Helpers | |
module TextHelper | |
# Use auto_link and friends from Rails 3. They do the right thing (tm). | |
remove_const(:AUTO_LINK_RE) if defined?(AUTO_LINK_RE) | |
AUTO_LINK_RE = %r{ | |
( https?:// | www\. ) |
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 ApplicationController < ActionController::Base | |
include Intercession | |
before_filter :load_skin | |
before_filter :require_user | |
before_filter :require_matching_skin | |
before_filter :require_admin | |
def load_skin | |
session.skin = Skin.for_request(request) |
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 'nokogiri' | |
ugly = Nokogiri::HTML ARGF | |
tidy = Nokogiri::XSLT File.open('tidy.xsl') | |
nice = tidy.transform(ugly).to_html | |
puts nice |
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
delete_all [prefix=mephisto_production/bin_logs, @name=airbladesoftware]... | |
size: 2 | |
delete mephisto_production/bin_logs/mysql-bin.000001: true | |
size: 1 | |
...done |
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
# Rackup file for serving up a static site from a "public" directory | |
# | |
# Useful for chucking a static site on Heroku | |
class IndexRewriter | |
def initialize(app) @app = app end | |
def call(env) | |
env["PATH_INFO"].gsub! /\/$/, '/index.html' | |
@app.call(env) | |
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
Then /^(?:I|they) should see the email delivered from "([^"]*?)"$/ do |text| | |
#current_email.should be_delivered_from(text) | |
should_be_delivered_from(text) | |
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
$ rake test | |
(in /Users/andy/business/open_source/paper_trail) | |
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -I"lib:lib:test" "/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" "test/paper_trail_controller_test.rb" "test/paper_trail_model_test.rb" "test/paper_trail_schema_test.rb" "test/thread_safe_test.rb" | |
/Library/Ruby/Site/1.8/rubygems.rb:233:in `activate': can't activate actionpack (= 2.3.8, runtime) for [], already activated actionpack-3.0.0 for [] (Gem::LoadError) | |
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:35:in `require' | |
from ./test/test_helper.rb:8 | |
from ./test/paper_trail_controller_test.rb:1:in `require' | |
from ./test/paper_trail_controller_test.rb:1 | |
from /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `load' | |
from /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5 |
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
keywords = [] # the keywords belonging to @publication at the time | |
keywords_versions = Version.all :item_type => 'Keyword', :publication_id => @publication.id | |
keywords_versions.group_by(&:item_id).each do |item_id, versions| | |
v = versions.first :conditions => ['created_at > ?', (@publication.created_at - 3.seconds)] | |
keywords << (v ? v.reify : Keyword.find(item_id)) | |
end | |
variables = keywords.map do |keyword| |
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 PublicationsController < ActionController::Base | |
def show | |
@publication = Publication.find params[:id] | |
# If you need a specific version, get that from the URL. | |
version_id = ... | |
@publication = @publication.versions.find version_id | |
keywords = [] # the keywords belonging to @publication at the time | |
keywords_versions = Version.all :item_type => 'Keyword', :publication_id => @publication.id |
OlderNewer