All pastes #929468 Raw Edit

Unnamed

public ruby v1 · immutable
·published 2008-03-05 20:10 UTC
rendered paste body
class Special < ActiveRecord::Basebelongs_to :barvalidates_presence_of :bar_id, :name, :dayvalidates_numericality_of :price, :if => Proc.new{ |p| not p.price.blank? }def self.get_for_week(bar_id)  specials = Special.find(:all, :conditions => ['bar_id = ?', bar_id])  Special.weekify(specials)enddef self.weekify(specials)  week = Array.new(7){|i| specials.find_all{|s| s.day == i}}  week.each_with_index{ |day, i| week[i] = [nil] if day.empty? }end