This repo is an experiment and strays from the standard Rails way.
A useful strategy for building multi-model forms in Rails is to use a form object which composes other model objects. This is well described on the Code Climate Blog. One barrier to this strategy is validating the form object without duplicating the validation logic already described by component models. component_validations
is an attempt to remove this barrier by mapping ActiveModel object attributes to their component models and delegating all validations without using validates_associated
or accepts_nested_attributes
.
class Signup
include ActiveModel::Validations
validates_component Account, :name => :account_name, :subdomain => :account_subdomain
validates_component User, {
:name => :name,
:email => :email,
:password => :password,
:password_confirmation => :password_confirmation
}
# ...
end
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request