0.0
No commit activity in last 3 years
No release in over 3 years
This is simple wrapper on the model to prepare forms for all validation usage cases
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
~> 0.7
~> 2.12
~> 10.4
~> 3.0
 Project Readme

ShadowForm

Gem Version Build Status Dependency Status Code Climate

Fat model with validation in all cases always causes problems in the future. So my solution is ShadowForm. Now you can have your original model without validation and the form when you need it.

Installation

Add this line to your application's Gemfile:

gem 'shadow_form'

And then execute:

$ bundle

Or install it yourself as:

$ gem install shadow_form

How it works

You have your active_record or active_model model:

class User
  include ActiveModel::Model
  attr_accessor :name, :email, :password
end

And for example register form

class UserRegistrationForm < ShadowForm::Core
  shadow_of User
  give_name 'RegisterForm` # optional
  validation do
    validates :email, presence: true
    validates :password, presence: true
  end
end

And now you have UserRegistrationForm like User + Validation

Contributing

  1. Fork it ( https://github.com/[my-github-username]shadow_form/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request