ScaffoldPlusAnswerOne » 履歴 » バージョン 13
Yuumi Yoshida, 2011-08-07 10:48
1 | 6 | Yuumi Yoshida | h1. 演習1 解答例 |
---|---|---|---|
2 | |||
3 | |||
4 | |||
5 | h2. 作業手順 |
||
6 | |||
7 | <pre> |
||
8 | 12 | Yuumi Yoshida | rails new todo_app |
9 | cd todo_app |
||
10 | rails generate scaffold todo due:date task:string |
||
11 | 2 | Yuumi Yoshida | rake db:migrate |
12 | 12 | Yuumi Yoshida | rails server |
13 | 6 | Yuumi Yoshida | </pre> |
14 | 1 | Yuumi Yoshida | |
15 | |||
16 | 6 | Yuumi Yoshida | h2. 変更点 |
17 | 2 | Yuumi Yoshida | |
18 | 6 | Yuumi Yoshida | |
19 | |||
20 | h3. app/controllers/todos_controller.rb の indexメソッド |
||
21 | |||
22 | |||
23 | 1 | Yuumi Yoshida | Todo.find にソートオプション を追加 |
24 | |||
25 | 7 | Yuumi Yoshida | <pre><code class="color"> |
26 | def index |
||
27 | 13 | Yuumi Yoshida | @todos = Todo##(.sort(:due))##.all |
28 | 1 | Yuumi Yoshida | |
29 | respond_to do |format| |
||
30 | 4 | Yuumi Yoshida | format.html # index.html.erb |
31 | 6 | Yuumi Yoshida | format.xml { render :xml => @todos } |
32 | end |
||
33 | end |
||
34 | 11 | Yuumi Yoshida | </code></pre> |