Skip to content

Instantly share code, notes, and snippets.

@Electron-libre
Created February 10, 2011 10:51
Show Gist options
  • Save Electron-libre/820311 to your computer and use it in GitHub Desktop.
Save Electron-libre/820311 to your computer and use it in GitHub Desktop.
def integrity
dependent_attributes = %w(time_credit establishment_cost)
nullity_proc = lambda{|attr| send(attr.to_sym).nil? || send(attr.to_sym).zero?}
dependent_attributes.each_index do |i|
if nullity_proc.call(dependent_attributes[i]) && !nullity_proc.call(dependent_attributes[i-1])
errors.add(dependent_attributes[i].to_sym, I18n.t("#{dependent_attributes[i]}_empty", :scope => [:models, :destinations, :integrity]))
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment