This file contains hidden or 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 Kernel | |
def ensure_a | |
self.is_a?(Array) ? self : [self] | |
end | |
end |
This file contains hidden or 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 Thing | |
attr_accessor :name, :age | |
end | |
class Thing < Struct.new(:name, :age) | |
end |
This file contains hidden or 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
# in config/routes.rb | |
map.blog "/blog", :controller => "blog" | |
map.blog "/blog/:id", :controller => "blog", :action => "show", :id => id |
This file contains hidden or 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
# steroids_on_steroids | |
class Steroids | |
def initialize | |
Steroids.new | |
end | |
end |
This file contains hidden or 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
ActionController::Routing::Routes.draw do |map| | |
map.with_options :controller => "info" do |info| | |
%w[action1 action2 whatever yada1 yada2 yada3].each do |action| | |
info.send(action, action, :action => action) | |
end | |
info.home "/" | |
info.root | |
end | |
This file contains hidden or 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
form.formtastic fieldset ol li { display: block; margin-bottom:.5em; } | |
form.formtastic fieldset {border:1px solid #CCC; width:400px; padding:15px; margin:15px;} | |
form.formtastic fieldset ol li label { display:block; width:200px; float:none; padding-top:.2em; } | |
form.formtastic legend { margin-bottom: 15px;} | |
form.formtastic legend span { background-color: #666; padding:8px; color:#FFF; } | |
form.formtastic .numeric { width:60px;} |
This file contains hidden or 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
@property.asking_price_type == 'Price' ? number_to_currency(@property.asking_price, :precision => 0) : "#{number_to_currency(@property.asking_price)}/SF" |
This file contains hidden or 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
require 'rubygems' | |
require 'httparty' | |
module Icontact | |
# This info was gleaned from developer.icontact.com | |
# Get a sandbox APP ID from here | |
APP_ID = "XXXXXXXXXXXXXXXXXXXXX" | |
This file contains hidden or 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 ActiveHash | |
class Base | |
def self.has_many(association_id, options = {}) | |
define_method(association_id) do | |
options = { | |
:class_name => association_id.to_s.classify, | |
:foreign_key => self.class.to_s.foreign_key | |
}.merge(options) |
This file contains hidden or 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
require 'rubygems' | |
require 'sinatra' | |
require 'active_hash' | |
### HAS_MANY AND BELONGS_TO | |
module ActiveHash | |
class Base | |
class << self | |