Skip to content

Instantly share code, notes, and snippets.

@matthuhiggins
Created November 9, 2010 05:42
Show Gist options
  • Save matthuhiggins/668764 to your computer and use it in GitHub Desktop.
Save matthuhiggins/668764 to your computer and use it in GitHub Desktop.
can haz namespaces
belongs_to :session, :class_name => "Statistics::Session"
config.active_record.observers = 'statistics/request_observer'
short_request:
milliseconds: 1
session: <%= Fixtures.identify(:long_session) %>
long_session:
start: 2008-08-13 21:32:32
end: 2008-08-13 21:32:32
short_request:
milliseconds: 1
session: long_session
create_table :statistics_sessions do |t|
t.datetime :start, :end
end
change_table :statistics_requests do |t|
t.integer :session_id
end
ActiveRecord::Base.class_eval do
def self.table_name
name.split("::").map { |package| package.underscore.pluralize }.join("_")
end
end
class Statistics::Request < ActiveRecord::Base
belongs_to :session
end
class Statistics::RequestObserver < ActiveRecord::Observer
def after_create(request)
puts "We got a hit!!!"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment