-
-
Save scottjacobsen/6629675 to your computer and use it in GitHub Desktop.
This file contains 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
#assuming schema is | |
# table turbines | |
# id integer | |
# turbine_type_id integer | |
# table turbine_types | |
# id integer | |
# name string | |
class Turbine < ActiveRecord::Base | |
belongs_to :turbine_type # fk is in turbines, so belongs_to belongs here. | |
end | |
class TurbineType < ActiveRecord::Base | |
has_many :turbines | |
end | |
show.html.erb | |
<p id="notice"><%= notice %></p> | |
<p> | |
<strong>Name:</strong> | |
<%= @turbine.name %> | |
</p> | |
<p> | |
<strong>Type:</strong> | |
<%= @turbine.turbine_type.name %> | |
</p> | |
<%= link_to 'Edit', edit_turbine_path(@turbine) %> | | |
<%= link_to 'Back', turbines_path %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment