rails:active_record
差分
このページの2つのバージョン間の差分を表示します。
| 両方とも前のリビジョン前のリビジョン次のリビジョン | 前のリビジョン | ||
| rails:active_record [2024/01/10 09:54] – [テーブル結合] nullpon | rails:active_record [2024/01/10 14:30] (現在) – nullpon | ||
|---|---|---|---|
| 行 71: | 行 71: | ||
| ===== nemed_scope ===== | ===== nemed_scope ===== | ||
| - | (rails 2.1 or later) | ||
| よくある検索条件をメソッド化できる。 | よくある検索条件をメソッド化できる。 | ||
| <code rubyt> | <code rubyt> | ||
| User < ActiveRecord:: | User < ActiveRecord:: | ||
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| end | end | ||
| </ | </ | ||
| 行 147: | 行 146: | ||
| 検索時は | 検索時は | ||
| - | LimitedItem.find(:all) | + | LimitedItem.all |
| とすれば、 | とすれば、 | ||
| select * from items where type = " | select * from items where type = " | ||
| 行 160: | 行 159: | ||
| class ItemsController | class ItemsController | ||
| def index | def index | ||
| - | @items = Item.find(:all) | + | @items = Item.all |
| end | end | ||
| end | end | ||
rails/active_record.1704880466.txt.gz · 最終更新: by nullpon