Socket
Book a DemoInstallSign in
Socket

activeadmin-reform

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

activeadmin-reform

1.1.0
bundlerRubygems
Version published
Maintainers
1
Created
Source

Build Status Test Coverage Code Climate Gem Version

ActiveAdmin Reform

This gem adds integration between ActiveAdmin and Reform. So you may use form objects for your forms.

The purpose of this gem is to provide ability to define custom ActiveAdmin-specific validations for your models. Using form objects allows you to define such validations without cluttering model's code and simplifies building test objects.

Installation

Add this line to your application's Gemfile:

gem 'activeadmin-reform'

And then execute:

$ bundle

Or install it yourself as:

$ gem install activeadmin-reform

Usage

Define your form object and include our mixin (ActiveAdmin::Reform::ActiveRecord) into it:

require 'reform'

class AuthorForm < Reform::Form
  include ActiveAdmin::Reform::ActiveRecord

  model :author

  property :last_name, validates: { presence: true }
  property :name
end

Specify form class for ActiveAdmin resource:

ActiveAdmin.resource Author do
  form_class AuthorForm
  
  form do |f|
    f.semantic_errors(*f.object.errors.keys)

    f.inputs do
      f.input :name
      f.input :last_name
    end

    f.actions
  end
end

Now ActiveAdmin will use Reform form object to validate form. Note, you must explicitly define form for resource.

By default ActiveAdmin will not use Reform, but if you want to reopen resource and disable form object usage, pass false instead of class:

ActiveAdmin.resource Author do
  form_class false
end

Contributing

The contributing guide is a good place to start.

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 14 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.