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