Last active
October 19, 2015 15:53
-
-
Save mrsweaters/77035b2963f14a562295 to your computer and use it in GitHub Desktop.
Engineering 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <body> | |
| <% @warehouses.each do |warehouse| %> | |
| <h2><%= warehouse %></h2> | |
| <ul class="trucks"> | |
| <% warehouse.trucks.each do |truck| %> | |
| <li>ID: <%= truck.id %><br>Miles: <%= truck.miles %></li> | |
| <% end %> | |
| <% end %> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Truck { id, name, miles } | |
| class Truck < ActiveRecord::Base | |
| belongs_to :warehouse | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Warehouse { id, name, description, location } | |
| class Warehouse < ActiveRecord::Base | |
| has_many :trucks | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class WarehouseController < ApplicationController | |
| def index | |
| @warehouses = Warehouse.order('created_at asc') | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment