Skip to content

Instantly share code, notes, and snippets.

View ratnikov's full-sized avatar

Dmitry Ratnikov ratnikov

  • wonder.com
  • New York, NY
View GitHub Profile
class ApplicationController
after_filter :record_create, :only => [ :create ]
after_filter :record_update, :only => [ :update ]
after_filter :record_destroy, :only => [ :destroy ]
private
def record_create
Event.create! :record => record, :controller => name, :action => :create unless record.previous_changes.empty?
end
class A
def initialize
@foo = "bar"
end
end
class B < A
def initialize
super # invoke the super initialize
@available_fetchers = Fetcherr.all
if @available_fetchers.empty?
puts "No fetchers found"
else
@available_fetchers.each do |fetcher|
puts "Loading the #{fetcher.name} fetcher"
klass = Class.new do
include HTTParty
module Invite
module Inviter
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
attr_reader :invite_block
= form_for ([@ticket.ticketable, @ticket]) do |f|
= debug @ticket
= debug ticket.ticketable
= f.error_messages
%p
= f.label :title, "Brief Title for Issue"
= f.text_field :title
%p
= f.label :call_type
%br/
=> Booting WEBrick
=> Rails 3.0.3 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-01-18 20:53:12] INFO WEBrick 1.3.1
[2011-01-18 20:53:12] INFO ruby 1.9.2 (2010-12-25) [x86_64-darwin10.5.0]
[2011-01-18 20:53:12] INFO WEBrick::HTTPServer#start: pid=3154 port=3000
Started POST "/tickets" for 127.0.0.1 at 2011-01-18 20:53:44 -0500
Started GET "/companies/3/tickets/new" for 127.0.0.1 at 2011-01-18 20:34:21 -0500
Processing by TicketsController#new as HTML
Parameters: {"company_id"=>"3"}
SQL (0.4ms) SHOW TABLES
User Load (0.3ms) SELECT `users`.* FROM `users` WHERE (`users`.`id` = 1) LIMIT 1
CACHE (0.0ms) SELECT `users`.* FROM `users` WHERE (`users`.`id` = 1) LIMIT 1
Completed in 98ms
ActiveRecord::RecordNotFound (Couldn't find Company without an ID):
app/controllers/tickets_controller.rb:54:in `find_company'
class CompaniesController < ApplicationController
# GET /companies
# GET /companies.xml
def index
@companies = Company.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @companies }
end
class Admin::AuditsController < ApplicationController
def create
@audit = Audit.new params[:audit]
if @audit.valid?
# ...
else
render :action => 'new'
end
end