more crap for 15.14

This commit is contained in:
Dan Buch 2011-08-10 22:51:14 -04:00
parent 7329bcdeb4
commit 36c69e95a4
2 changed files with 28 additions and 2 deletions

View File

@ -5,4 +5,16 @@ class ListController < ApplicationController
@list = [1, "string", :symbol, ['list']]
end
def shopping_list
@list = [ListItem.new(4, 'aspirin'), ListItem.new(199, 'succotash')]
end
end
class ListItem
attr_accessor :name, :id
def initialize(id, name)
@id, @name = id, name
end
end

View File

@ -1,2 +1,16 @@
<h1>List#shopping_list</h1>
<p>Find me in app/views/list/shopping_list.html.erb</p>
<h2>My shopping list</h2>
<ul>
<% @list.each do |item| %>
<li><%= item.name %>
<%= link_to 'Delete', {:action => 'delete', :id => item.id} %>
</li>
<% end %>
</ul>
<h2>Add new item</h2>
<%= form_tag :action => 'new' do %>
<label for="product_name">Item:</label><%= text_field "product", "name" %>&#x00A;
<%= submit_tag "Add new item" %>
<% end %>