Combined Errors
Sometimes you want to use SimpleForm and have 2 or 3 inputs on the same line. Like with an address.
= simple_form_for @profile do |f|
.form-inputs
= f.input :name
= f.input :address_line_1
= f.input :address_line_2
= f.input :city_state_zip do
= f.input_field :city, class: 'input-medium'
= f.input_field :state, collection: State.all
= f.input_field :zip, class: 'input-small'
But it would be nice if the errors still stacked up nicely. That's where Combined Errors comes in:
class Profile < ActiveRecord::Base
# ...
validates :city, presence: true
validates :state, presence: true
validates :zip, presence: true
combine_errors :city_state_zip, [:city, :state, :zip]
end
Installation
Add this line to your application's Gemfile:
gem 'combined_errors'
And then execute:
$ bundle
Or install it yourself as:
$ gem install combined_errors
Contributing
- 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