Skip to content

Instantly share code, notes, and snippets.

@gerep
Last active September 24, 2015 16:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gerep/8d92af25408b8d472e9d to your computer and use it in GitHub Desktop.
Save gerep/8d92af25408b8d472e9d to your computer and use it in GitHub Desktop.
class TransactionCost < ActiveRecord::Base
belongs_to :company
belongs_to :app
has_many :range_costs
accepts_nested_attributes_for :range_costs, allow_destroy: true, reject_if: lambda { |a| a[:to].blank? && a[:from].blank? && a[:cost].blank? }
validates :app_id, uniqueness: true
validates :range_costs, presence: true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment