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 Game | |
attr_reader :secret | |
def initialize | |
@secret = Secret.new | |
end | |
def console_play | |
bulls = -1 | |
while bulls != 4 |
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 A | |
has_many :abcees | |
has_many :bees, :through => :abcees | |
has_many :cees, :through => :abcees | |
end | |
class Bee | |
end | |
class Cee |
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 LoginController < ApplicationController | |
skip_before_filter :check_login | |
skip_before_filter :check_rights | |
include LoginMethods | |
end | |
> LoginController.action_methods | |
=> #<Set: { ... }> # only action methods from ApplicationController show up here |
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
#!/usr/bin/env ruby | |
# | |
# = USAGE | |
# rails_test (f|functional|u|unit|p|performance|i|integration) test_case_name test_name | |
# | |
# = SYNOPSIS | |
# | |
# rails_test f customers | |
# # will run functional/customers_controller.rb | |
# |
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 SomeController < ApplicationController | |
before_filter :check_from_invoice | |
before_filter :session_is_empty, :only => [:create] | |
def check_from_invoice | |
if some_condition | |
skip_before_filter :session_is_empty | |
end | |
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
Master::Application.routes.draw do | |
# ... bunch of resources | |
# resource-less controllers | |
{ 'statistics' => %w(select_period filter drop_filter apply_filters | |
add_filter show get_filter_values | |
), | |
'warehouse' => %w(delivery delivery_with_po delivery_without_po | |
add_product_field shipment_csv_line shipment_put | |
shipment_csv |
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
# ... | |
def sema_key; "stock-observer-semaphores"; end | |
# make sure the stock off all coupled products is always equal | |
def update_coupled_stock(stock) | |
# get the current list of semaphores | |
semaphores = Rails.cache.read(sema_key) || [] | |
# when this stocks is already being updated, leave now |
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 Member < ActiveRecord::Base | |
SALT = "some lengthy secret" | |
before_create :hash_password | |
# in rails 2 this would break the callback chain and set the error message | |
# in rails 3 it doesnt | |
# | |
def hash_password | |
if password == password_confirm |
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
module ActiveSupport | |
# log errors in red | |
class BufferedLogger | |
alias_method :orig_error, :error | |
def error msg | |
if Rails.env != :production | |
msg = "\e[1;31m#{msg}\e[0m" | |
end | |
orig_error msg |
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
#!/bin/sh | |
# shell scripting is easy. | |
# | |
# just do what you would normaly do on the shell to get those directories | |
# present | |
mkdir tmp | |
mkdir -p log/pids |