воскресенье, 28 декабря 2008 г.

Динамические файндеры

# No posts with name 'Active' exists, so a post is created and stored into post object
post = Post.find_or_create_by_name("Active")

# A post is found with the name 'Active' and stored into the post object
post = Post.find_or_create_by_name("Active")

# A new post object is create with its name 'Record' but is not saved into database
post = Post.find_or_initialize_by_name("Record")
и прочие вещи можно узреть на
http://www.jumbabox.com/2008/06/ruby-on-rails-dynamic-finders/

Комментариев нет:

Отправить комментарий