【发布时间】:2013-09-15 21:49:28
【问题描述】:
我在rails 上在线使用tutorial,但我被卡住了。这些是我的控制器和视图文件:
/app/controllers/todos_controller.rb:
class TodosController < ApplicationController
def index
@todo_array = [ "Buy Milk", "Buy Soap", "Pay bill", "Draw Money" ]
end
end
/app/views/todos/index.html.erb:
<title>Shared Todo App </title>
<h1>Shared Todo App</h1>
<p>All your todos here</p>
<ul>
<% @todo_array.each do |t| %>
<li> #todo item here </li>
<% end %>
</ul>
我需要更改代码#todo item here 以显示数组中的实际待办事项。所以我得到的输出为:
Shared Todo App
All your todos here
- Buy Milk
- Buy Soap
- Pay bill
- Draw Money
【问题讨论】:
-
<% @todo_array.each do |t| %> <li> <%= t %> </li> <% end %> -
标签: ruby-on-rails actionview actioncontroller