From 2535439ad0b4c201f7a8e012467099e534462ed1 Mon Sep 17 00:00:00 2001 From: "Rico Sta. Cruz" Date: Wed, 21 Mar 2012 14:15:34 +0800 Subject: [PATCH] Rails models. --- ios.md | 4 ---- rails-models.md | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/ios.md b/ios.md index f3d133978..96ac642be 100644 --- a/ios.md +++ b/ios.md @@ -1,7 +1,3 @@ -Path to Installous downloads: - - /private/var/mobile/Documents/Installous/Downloads - Multiple Exchange accounts: scp root@iphone.local:/private/var/mobile/Library/Preferences/com.apple.accountsettings.plist . diff --git a/rails-models.md b/rails-models.md index 20d367c73..8e19807a7 100644 --- a/rails-models.md +++ b/rails-models.md @@ -84,6 +84,22 @@ And in migrations: t.references :post, :polymorphic => true end +### Dynamic attribute-based finders + + # Returns one record + Person.find_by_name(name) + Person.find_last_by_name(name) + Person.find_or_create_by_name(name) + + # Returns a list of recordns + Person.find_all_by_name(name) + + # Add a bang to make it raise an exception + Person.find_by_name!(name) + + # Use `scoped` instead of `find` + Person.scoped_by_user_name + Validation ----------