search for: to_c

Displaying 2 results from an estimated 2 matches for "to_c".

Did you mean: t_c
2006 Jul 23
8
belongs_to :through ?
Suppose I have a belongs_to relationship and the thing it belongs to, belongs in turn to something else. For example, I would like to do: belongs_to :city belongs_to: :county, :through => :city While it is not too much trouble to do obj.city.county, there are times when I need to iterate through the attributes and include this second-order attribute. Special code to handle this messes up
2006 Mar 03
0
unused composed_of bits
..., to_html and a number of conversions and bang conversions attr_reader :temp, :units def initialize( temperature, units = "F" ) unless valid_units?(units) units = "F" end @temp = temperature = ((10 * temperature).to_f.round)/10.0 @units = units.upcase end def to_c convert_to("C") end ... etc. So in my app model: class Profile < ActiveRecord::Base composed_of :temperature, :class_name => Temperature, :mapping => [ :temp, :temp ] def before_save self.temperature.to_f! end The table corresponding to Profile...