Skip to content

Instantly share code, notes, and snippets.

Phil McClure overture8

Block or report user

Report or block overture8

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View find_by_date.rb
def find_by_date
@posts = Post.find(:all,
:conditions => ["monthname(created_at) = ? AND year(created_at) = ?",
params[:month], params[:year]])
render :action => "index"
end
View using_abstraction2.rb
rep_gen = ReportGenerator.new
my_reports = [XmlReport.new, TextReport.new, HtmlReport.new, PdfReport.new]
my_reports.each do |report|
rep_gen.print_report(report)
end
View cache_page.rb
class PeopleController < ApplicationController
caches_page :index
end
View expiring_cache.rb
def create
expire_page :action => :index
end
def update
expire_page :action => :index
end
View sweeper_actions.rb
class PeopleController < ApplicationController
cache_sweeper :person_sweeper, :only => [:create, :update, :destroy] ...
end
View database.yml
development:
adapter: mysql
encoding: utf8
reconnect: false
database: dablog_development
pool: 5
username: root
password:
host: localhost
View sweeper.rb
class PersonSweeper < ActionController::Caching::Sweeper
observe Person
def after_create(person)
expire_cache_for person
end
def after_update(person)
expire_cache_for person
end
View associations.rb
class Company < ActiveRecord::Base
has_many :addresses
end
class Address < ActiveRecord::Base
belongs_to :company
end
You can’t perform that action at this time.