My Recent Pastes (53 and counting)
All Pasties (over 53 and counting)
Below are summaries of the 15 most recent pasties by Pat Allan.
September 24, 2007
2:16AM EDT
by Pat Allan
View more (19 lines)
1 2 3 4 5 |
def rrp # ... end def rrp_to(currency) |
September 20, 2007
1:20AM EDT
by Pat Allan
View more (11 lines)
1 2 3 4 5 |
class ProjectMilestone < ActiveRecord:Base # ... def self.find(*args) |
September 19, 2007
12:18AM EDT
by Pat Allan
View more (6 lines)
1 2 3 4 5 |
@topics = Topic.paginate(
:page => params[:page],
:conditions => "forum_id = #{@forum.id} AND deleted_at IS NULL",
:order => "topics.updated_at desc",
:per_page => 15
|
September 19, 2007
12:18AM EDT
by Pat Allan
View more (40 lines)
1 2 3 4 5 |
class Array
def with(user)
return self.each { |item| item.read = true } if user.nil?
ids, sql, conditions = [], "", ""
|
September 18, 2007
10:03AM EDT
by Pat Allan
View more (33 lines)
1 2 3 4 5 |
class Item < ActiveRecord::Base
set_table_name <<-SQL
(SELECT p.id, p.subject, p.content, p.created_by, p.updated_by, p.deleted_by,
p.created_at, p.updated_at, p.deleted_at, NULL as url, NULL as name,
NULL as description, tg.taggable_type as type,
|
September 18, 2007
9:56AM EDT
by Pat Allan
View more (40 lines)
1 2 3 4 5 |
class Item < ActiveRecord::Base
def self.abstract_class?
true
end
|
September 17, 2007
10:38PM EDT
by Pat Allan
View more (25 lines)
1 2 3 4 5 |
def self.import_from_titlepage(ean)
config = Configuration.load
RBook::TitlePage::Client.open(config.titlepage_username, config.titlepage_password) do |tp|
result = tp.find(ean)
unless result.nil?
|
September 06, 2007
12:56AM EDT
by Pat Allan
View more (15 lines)
1 2 3 4 5 |
module ActiveRecord
class Base
class << self
def validates_value_of(*attrs)
options = attrs.last.is_a?(Hash) ? attrs.pop : {}
|
September 04, 2007
8:49PM EDT
by Pat Allan
View more (26 lines)
1 2 3 4 5 |
class Invoice < ActiveRecord::Base
# ...
define_index do |index|
index.includes(:id).as.invoice_id
|
September 04, 2007
11:05AM EDT
by Pat Allan
View more (34 lines)
1 2 3 4 5 |
# to put in RAILS_ROOT/config/ultrasphinx # can be namespaced individually (development.base) indexer |
September 04, 2007
10:05AM EDT
by Pat Allan
View more (19 lines)
1 2 3 4 5 |
index = ThinkingSphinx::Index.new(Invoice) index.includes.address.state index.includes.customer.postal_address.country index.includes.items.edition.ean index.includes.items.order_item.edition.name |
September 04, 2007
9:45AM EDT
by Pat Allan
View more (6 lines)
1 2 3 4 5 |
index = ThinkingSphinx::Index.new(Invoice) index.includes.address.state index.includes.customer.postal_address.country index.includes.items.edition.ean index.includes.items.order_item.edition.name |
September 03, 2007
11:04PM EDT
by Pat Allan
View more (7 lines)
1 2 3 4 5 |
class MyController < ApplicationController
self.template_root = "custom/path/instead/of/app/views"
def self.controller_path
"custom/controller/folder" # ie. app/views/THIS_FOLDER/action
|
September 03, 2007
11:02PM EDT
by Pat Allan
1 2 3 |
class MyController < ApplicationController self.template_root = "custom/path/instead/of/app/views" end |
Pastie