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 User < ActiveRecord::Base | |
# I like the conciseness of the new syntax here | |
validates :email, length: { maximum: 255 }, presence: true | |
# but like the hashrocket syntax here | |
before_save :hash_password, :if => :password_hash_required? | |
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
>> case "String".class | |
>> when String | |
>> puts "I'm a string" | |
>> else | |
?> puts "I can't tell what I am" | |
>> end | |
I can't tell what I am |
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
Anil Wadghule has won $30 credit from Heroku | |
Nobuhiro IMAI has won $30 credit from Heroku | |
Federico Brubacher has won $36 account from Mad Mimi | |
Jeroen van Dijk has won $36 account from Mad Mimi | |
Rizwan Reza has won $36 account from Mad Mimi | |
Santiago Pastorino has won $75 account from Mad Mimi | |
Diego Algorta has won $189 account from Mad Mimi | |
pleax has won 1 Annual Subscription to LessAccounting or LessTimeSpent or LessProjects from Less Everything | |
Simon Jefford has won $25 Amazon Gift Card from Bob Martens | |
Adrian Sanchez has won 15 Credit pack from BDDCasts |
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
[dev]>> a = User.new | |
=> #<User id: nil avatar_file_name: nil, avatar_content_type: nil, avatar_file_size: nil, avatar_updated_at: nil, created_at: nil, updated_at: nil> | |
[dev]>> a.avatar.url | |
=> "/images/original/missing.png" | |
[dev]>> a.avatar.path | |
=> nil | |
[dev]>> a.avatar.expiring_url |
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
Last login: Thu May 13 15:49:56 on ttys001 | |
~$ ruby -v | |
ruby 1.8.7 (2009-06-08 patchlevel 173) [universal-darwin10.0] | |
~$ rvm list | |
rvm Rubies | |
ree-1.8.6-20090610 [ x86_64 ] | |
ruby-1.8.6-p383 [ x86_64 ] | |
ruby-1.8.7-p248 [ x86_64 ] |
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 Post < ActiveRecord::Base | |
has_many :authors | |
has_many :post_comments | |
attr_accessor :post_authors_cache, :post_comments_cache | |
def post_authors | |
@post_authors_cache ||= begin | |
process_post |
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 Post < ActiveRecord::Base | |
has_many :authors | |
has_many :post_comments | |
attr_accessor :post_authors_cache, :post_comments_cache | |
def post_authors | |
process_post if post_authors_cache.nil? | |
post_authors_cache |
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 Post < ActiveRecord::Base | |
has_many :authors | |
attr_accessor :post_authors_cache | |
def post_authors_cache | |
@post_authors_cache ||= process_post_authors | |
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
# ------------------------------------------- | |
# Simple PostgreSQL Configuration File v. 8.4 | |
# ------------------------------------------- | |
# This file provides a simple configuration with the most common options | |
# which most users need to modify for running PostgreSQL in production, | |
# including extensive notes on how to set each of these. If your configuration | |
# needs are more specific, then use the standard postgresql.conf, or add | |
# additional configuration options to the bottom of this file. | |
# |
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
This example shows how to setup an environment running Rails 3 beta 3 under 1.9.2-head with a 'rails3' gem set. | |
∴ rvm update --head | |
# ((Open a new shell)) or do 'rvm reload' | |
# If you do not already have the ruby interpreter installed, install it: | |
∴ rvm install 1.9.2-head | |
# Switch to 1.9.2-head and gemset rails3, create if it doesn't exist. | |
∴ rvm --create use 1.9.2-head@rails3 |