summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
da20d3a)
Signed-off-by: Ira W. Snyder <devel@irasnyder.com>
class Coitem < ActiveRecord::Base
class Coitem < ActiveRecord::Base
- has_one :customer
- has_one :rentable
+ belongs_to :customer
+ belongs_to :rentable
validates_presence_of :customer_id
validates_presence_of :rentable_id
validates_presence_of :customer_id
validates_presence_of :rentable_id
class Customer < ActiveRecord::Base
class Customer < ActiveRecord::Base
- belongs_to :coitem # FIXME: I hunch this is wrong
validates_presence_of :name, :email, :phone, :address
validates_numericality_of :debt
validates_presence_of :name, :email, :phone, :address
validates_numericality_of :debt
class Rentable < ActiveRecord::Base
class Rentable < ActiveRecord::Base
- belongs_to :coitem # FIXME: I hunch this is wrong
validates_presence_of :title
validates_presence_of :genre
validates_presence_of :title
validates_presence_of :genre
<% for coitem in @coitems %>
<tr>
<% for coitem in @coitems %>
<tr>
- <td><%=h Customer.find(coitem.customer_id).name %></td>
- <td><%=h Rentable.find(coitem.rentable_id).title %></td>
+ <td><%=h coitem.customer.name %></td>
+ <td><%=h coitem.rentable.title %></td>
<% for column in Coitem.content_columns %>
<td><%=h coitem.send(column.name) %></td>
<% end %>
<% for column in Coitem.content_columns %>
<td><%=h coitem.send(column.name) %></td>
<% end %>