Skip to content

Instantly share code, notes, and snippets.

View coderxin's full-sized avatar
🦀

Andrejs Eisaks coderxin

🦀
  • Zürich, Switzerland
  • 17:31 (UTC +02:00)
  • X @coderxin
View GitHub Profile

An incomplete cheatsheet for rails 3. Things are added as they are required.

Active Record validations

# http://guides.rubyonrails.org/active_record_validations_callbacks.html

class SomeClass < ActiveRecord::Base

  # length
# Amadeusz Juskowiak <amadeusz@amanointeractive.com> 2012 - MIT License
# 1. Put inside helpers do .. end
# 2. Set CACHE_DIR to somewhere writable and private (like CACHE_DIR=File.dirname(__FILE__) + '/tmp'
# 3. Use it! You can use fragment_expire to remove cache with given name.
#
# Example:
# %h1 foo
# = cache_fragment(:report, 300) do
# - data = get_data_slowly
@coderxin
coderxin / list_of_countries.rb
Created June 9, 2012 18:23 — forked from Aupajo/list_of_countries.rb
List of countries in a handy Ruby array
COUNTRIES = [
"Afghanistan",
"Aland Islands",
"Albania",
"Algeria",
"American Samoa",
"Andorra",
"Angola",
"Anguilla",
"Antarctica",