module Forest::HasRepeatable

Public Instance Methods

has_repeatable(attribute, options = {}) click to toggle source
# File lib/forest/rails/active_record/has_repeatable.rb, line 6
def has_repeatable(attribute, options = {})
  serialize attribute, Array

  before_save :"remove_blank_#{attribute}"

  define_method(:"remove_blank_#{attribute}") do
    self.send(attribute).reject! { |a| a[:key].blank? && a[:value].blank? }
  end
end