search for: stockrulelevel

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

2006 Mar 29
3
Loading records during class definition
I''ve created a look-up table in my database that currently has 4 rows. I want to access these as constants in the application because that''s effectively what they are. I tried this... class StockRuleLevel < ActiveRecord::Base has_many :stock_rules SITE = find(:first, :conditions => "type_code = ''site''").id MAKE = find(:first, :conditions => "type_code = ''make''").id MODEL = find(:first, :conditio...
2006 Apr 05
0
Is this model ordering logical or crazy?
...def +(offset) RuleLevel.level_for_position(position + offset) end def -(offset) RuleLevel.level_for_position(position - offset) end def <=>(other) return -(position <=> other.position) end private def self.level_for_position(position) StockRuleLevel.find(:first, :conditions => "position = # {position}") end end Imagine I also have constants MAKE, RANGE, MODEL, DERIVATIVE in the class to get at the levels with positions 1, 2, 3, 4 respectively. Now it makes sense that a more general rule is "greater" than a more...