Repository is archived
No commit activity in last 3 years
No release in over 3 years
Help to format strings in Rails before validation of the Model.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

AutoFormatAttributes

AutoFormatAttributes helps to format string attributes from ActiveRecord or ActiveModel.

It works by adding a before_validation hook to the record.

Usage

class User < ActiveRecord::Base

  # the last name will be in UPPERCASE
  auto_upcase_attributes :last_name

  auto_capitalize_attributes :name, :first_name

  auto_downcase_attributes :profile_url
  
  auto_titleize_attributes :title
end

Installation

Add this line to your application's Gemfile:

gem 'auto_format_attributes'

And then execute:

$ bundle

Or install it yourself as:

$ gem install auto_format_attributes

License

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