FogBugz #62: correct has_one to belongs_to in model relationships.

This commit is contained in:
Roland 2011-07-16 21:52:24 +02:00
parent df0821b2b8
commit 7bbf17314d
2 changed files with 7 additions and 5 deletions

View file

@ -1,7 +1,7 @@
class Contact < ActiveRecord::Base
has_many :emails, :dependent => :destroy
has_many :phones, :dependent => :destroy
has_one :address
belongs_to :address
accepts_nested_attributes_for :emails, :reject_if => lambda { |a| a[:address].blank? }, :allow_destroy => true
accepts_nested_attributes_for :phones, :reject_if => lambda { |a| a[:nr].blank? }, :allow_destroy => true

View file

@ -25,10 +25,12 @@
<% end %>
</div>
<div class="threecol">
<%= c.street + " " + c.housenr %>
<br />
<%= c.plz + " " + c.place %><%= ", " unless c.country.blank? %>
<%= c.country %>
<% unless c.address.nil? %>
<%= c.address.street + " " + c.address.housenr %>
<br />
<%= c.plz + " " + c.place %><%= ", " unless c.country.blank? %>
<%= c.country %>
<% end %>
</div>
<div class="twocol">
<%= "&nbsp;".html_safe unless c.phones.count > 0 %>