Sha256: 1264b2639d540e7c336803b5d7fa63b1b444409e19ec82a571f7c0aec43df1e7

Contents?: true

Size: 408 Bytes

Versions: 5

Compression:

Stored size: 408 Bytes

Contents

class CategoryForm
  include ActiveForm::Form

  properties :title, on: :category

  self.main_model = :category

  validates :title, presence: true

  attr_accessor :user_ids

  def fill_attributes(attributes)
    super(attributes)
  end

  def save
    super do
      category.save
      category.users = user_ids.delete_if(&:empty?).map do |user_id|
        User.find(user_id)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
activeform-rails-0.0.5 spec/dummy/app/forms/category_form.rb
activeform-rails-0.0.4 spec/dummy/app/forms/category_form.rb
activeform-rails-0.0.3 spec/dummy/app/forms/category_form.rb
activeform-rails-0.0.2 spec/dummy/app/forms/category_form.rb
activeform-rails-0.0.1 spec/dummy/app/forms/category_form.rb