ScaffoldPlusAnswerOne » 履歴 » バージョン 14
Yuumi Yoshida, 2015-08-03 22:24
1 | 14 | Yuumi Yoshida | # 演習1 解答例 |
---|---|---|---|
2 | 6 | Yuumi Yoshida | |
3 | |||
4 | |||
5 | 14 | Yuumi Yoshida | ## 作業手順 |
6 | 6 | Yuumi Yoshida | |
7 | 14 | Yuumi Yoshida | ~~~ |
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 | 14 | Yuumi Yoshida | ~~~ |
14 | 1 | Yuumi Yoshida | |
15 | |||
16 | 14 | Yuumi Yoshida | ## 変更点 |
17 | 2 | Yuumi Yoshida | |
18 | 6 | Yuumi Yoshida | |
19 | 1 | Yuumi Yoshida | |
20 | 14 | Yuumi Yoshida | ### app/controllers/todos_controller.rb の indexメソッド |
21 | 6 | Yuumi Yoshida | |
22 | |||
23 | Todo.find にソートオプション を追加 |
||
24 | 1 | Yuumi Yoshida | |
25 | 14 | Yuumi Yoshida | |
26 | ~~~ |
||
27 | 1 | Yuumi Yoshida | def index |
28 | 13 | Yuumi Yoshida | @todos = Todo##(.sort(:due))##.all |
29 | 1 | Yuumi Yoshida | |
30 | respond_to do |format| |
||
31 | 4 | Yuumi Yoshida | format.html # index.html.erb |
32 | 6 | Yuumi Yoshida | format.xml { render :xml => @todos } |
33 | end |
||
34 | end |
||
35 | 14 | Yuumi Yoshida | ~~~ |