Skip to content

Commit e17f72b

Browse files
Week 4, assignment schneems#3
1 parent b4e3f62 commit e17f72b

3 files changed

Lines changed: 56 additions & 27 deletions

File tree

.idea/workspace.xml

Lines changed: 25 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@ Since we have a relationship between our products and our user we can show the o
253253

254254
Check your logs again, did the SQL change? Are there any new statements, why?
255255

256+
New statements that the User table was loaded. The new statements added require the use of the User table.
257+
256258

257259
#### Homework:
258260

app/views/products/index.html.erb

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,33 @@
1-
Hello world
1+
<% first_product = Product.first %>
2+
3+
<p>Product name: "<%= first_product.name %>", cost: $<%=first_product.price %>, Owner: <%= first_product.user.name %></p>
4+
5+
<p>Number of products: <%= Product.count %></p>
6+
7+
<b>List of all products</b>
8+
<ul>
9+
<% product_list = Product.all %>
10+
<% product_list.each do |pl| %>
11+
<li><%=pl.name %>
12+
<% end %>
13+
</ul>
14+
15+
16+
<!-- List all books owned by John-->
17+
<% name = 'Lacey Kutch' %>
18+
<b>List of books owned by <%= name %></b>
19+
<ul>
20+
<% User.where(:name => name).each do |u| %>
21+
<% Product.where(:user_id => u.id).each do |p| %>
22+
<li>User Name: <%= u.name %>, Book owned: <%=p.name %>
23+
<% end %>
24+
<% end%>
25+
</ul>
26+
27+
28+
229

330
<h2> I AMA View </h2>
431
<p>
532
Find me in <%= Rails.root.join("app", "views", "products", __FILE__ ) %>
6-
</p>
33+
</p>

0 commit comments

Comments
 (0)