ScaffoldPlusAnswerOne » 履歴 » バージョン 5
Yuumi Yoshida, 2008-01-13 17:15
| 1 | 1 | Yuumi Yoshida | = 演習1 解答例 = |
|---|---|---|---|
| 2 | |||
| 3 | 2 | Yuumi Yoshida | == 作業手順 == |
| 4 | {{{ |
||
| 5 | 5 | Yuumi Yoshida | rails todo |
| 6 | cd todo |
||
| 7 | 2 | Yuumi Yoshida | ruby script/generate scaffold todo due:date task:string |
| 8 | rake db:migrate |
||
| 9 | ruby scrip/server |
||
| 10 | }}} |
||
| 11 | |||
| 12 | 1 | Yuumi Yoshida | == 変更点 == |
| 13 | |||
| 14 | 2 | Yuumi Yoshida | === app/controllers/todos_controller.rb の indexメソッド === |
| 15 | 1 | Yuumi Yoshida | |
| 16 | 4 | Yuumi Yoshida | Todo.find にソートオプション を追加 |
| 17 | 1 | Yuumi Yoshida | |
| 18 | {{{ |
||
| 19 | 4 | Yuumi Yoshida | #!html |
| 20 | <pre class="wiki"> def index |
||
| 21 | @todos = Todo.find(:all<font color="red">, :order => 'due'</font>) |
||
| 22 | 1 | Yuumi Yoshida | |
| 23 | respond_to do |format| |
||
| 24 | format.html # index.html.erb |
||
| 25 | 4 | Yuumi Yoshida | format.xml { render :xml => @todos } |
| 26 | 1 | Yuumi Yoshida | end |
| 27 | end |
||
| 28 | 4 | Yuumi Yoshida | </pre> |
| 29 | 1 | Yuumi Yoshida | }}} |
| 30 | |||
| 31 | == ソースコード == |
||
| 32 | |||
| 33 | 3 | Yuumi Yoshida | 解答例のソースコードは http://www.ey-office.com/trac/rails/browser/tags/todo_q1で参照できます。 |