&pgid;
**rails勉強会一覧 [#dd041670]
#ls2(rails)
**Ruby on Rails勉強会一覧 [#dd041670]
#ls2(Ruby on Rails)
**第4回勉強会のネタ [#cdc3f5f5]
ネタもとは下記です。
-RubyOnRails を使ってみる 【第 3 回】 ActiveRecord
http://jp.rubyist.net/magazine/?0006-RubyOnRails
-vendor/activerecord/README
原文: http://api.rubyonrails.org/files/vendor/rails/activerecord/README.html
邦訳: http://wiki.fdiary.net/rails/?ActiveRecord
-Active Record Reference Documentation
http://rubyonrails.org/api/classes/ActiveRecord/Base.html
**日時 [#g4f8ac7b]
- 2006/08/11(金) 18:00くらい 〜
**参加者 [#u5cc1f6d]
-[[志田]](発表者) ([[アークウェブ:http://www.ark-web.jp]])
-[[竹村]]さん ([[アークウェブ:http://www.ark-web.jp]])
-[[進地]]さん ([[アークウェブ:http://www.ark-web.jp]])
#blikimore
** 動画 [#xcd2a900]
動画は全部で3つです。~
続きは[[rails/第4回勉強会 - Active Record Reference Documentation/動画]]にあります。~
続きは[[Ruby on Rails/第4回勉強会 - Active Record Reference Documentation/動画]]にあります。~
#blikimore
#htmlinsert(study/rails4-1.html)
** 生成 [#b2cab7cf]
+ハッシュで。
user = User.new(:name => "David", :occupation => "Code Artist")
user.name # => "David"
+blockで。
user = User.new do |u|
u.name = "David"
u.occupation = "Code Artist"
end
+空のオブジェクトをつくって。後から属性の設定。
user = User.new
user.name = "David"
user.occupation = "Code Artist"
** 追加または更新 [#q5539a36]
-saveまたは、save!メソッドで。
http://rubyonrails.org/api/classes/ActiveRecord/Base.html#M000905
--No record exists: Creates a new record with values matching those of the object attributes.
--A record does exist: Updates the record with values matching those of the object attributes.
-save!は
it raises a RecordNotSaved exception
** 検索 [#y1199cdc]
-findやfind_by_sql メソッドで。
http://rubyonrails.org/api/classes/ActiveRecord/Base.html#M000860
http://rubyonrails.org/api/classes/ActiveRecord/Base.html#M000861
** 削除 [#z7a7b5b1]
-delete
http://rubyonrails.org/api/classes/ActiveRecord/Base.html#M000865
-delete_all
-destory
all the callbacks are the triggered
-destory_all
** updateを使った更新 [#i74f7963]
-update
-update_all
-update_attribute
#blikifooter(志田)
#comment
tag: [[rails>tag/rails]], [[勉強会>tag/勉強会]]
tag: [[Ruby on Rails>tag/Ruby on Rails]], [[勉強会>tag/勉強会]]