Rails find_or_initialize_by.

This commit is contained in:
Rico Sta. Cruz 2012-03-21 16:22:20 +08:00
parent ef98d1a6e7
commit 6295e7e882
1 changed files with 2 additions and 1 deletions

View File

@ -90,6 +90,7 @@ And in migrations:
Person.find_by_name(name)
Person.find_last_by_name(name)
Person.find_or_create_by_name(name)
Person.find_or_initialize_by_name(name)
# Returns a list of recordns
Person.find_all_by_name(name)
@ -97,7 +98,7 @@ And in migrations:
# Add a bang to make it raise an exception
Person.find_by_name!(name)
# Use `scoped` instead of `find`
# You may use `scoped` instead of `find`
Person.scoped_by_user_name
Validation