I have the following models installed:
class Contact < ActiveRecord::Base belongs_to :band belongs_to :mode validates_presence_of :call, :mode validates_associated :mode, :band validates_presence_of :band, :if => :no_freq? validates_presence_of :freq, :if => :no_band? protected def no_freq? freq.nil? end def no_band? band.nil? end end class Band < ActiveRecord::Base has_many :logs end class Mode < ActiveRecord::Base has_many :logs end
When I enter a frequency in my new view, it does not allow me to specify a range if a frequency is entered. This creates a problem in my other views, because the group is now zero. How to allow the group not to be indicated and just display as empty in my index and display the views, and then in the edit window to allow it to be indicated at a later point in time.
I was able to get my index to display a space by doing:
contact.band && contact.band.name
But I'm not sure if this is the best approach, and I'm not sure how to apply a similar solution to my other views.
Thanks a lot for newb rails!
source share