strip_attributes - :hocho: An ActiveModel extension that automatically strips all attributes of leading and trailing whitespace before validation

  •        13

StripAttributes is an ActiveModel extension that automatically strips all attributes of leading and trailing whitespace before validation. If the attribute is blank, it strips the value to nil by default.It works by adding a before_validation hook to the record. By default, all attributes are stripped of whitespace, but :only and :except options can be used to limit which attributes are stripped. Both options accept a single attribute (only: :field) or arrays of attributes (except: [:field1, :field2, :field3]).



Related Projects

active_attr - What ActiveModel left out

  •    Ruby

ActiveAttr is a set of modules that makes it easy to create plain old ruby models with functionality found in ORMs, like ActiveRecord, without reinventing the wheel. Think of ActiveAttr as the stuff ActiveModel left out. ActiveAttr is distributed as a rubygem on

validates_timeliness - Date and time validation plugin for ActiveModel and Rails

  •    Ruby

Complete validation of dates, times and datetimes for Rails 4.x and ActiveModel. If you a looking for the old version for Rails 3.x go here.

elasticsearch-rails - Elasticsearch integrations for ActiveModel/Record and Ruby on Rails

  •    Ruby

Elasticsearch client and Ruby API is provided by the elasticsearch-ruby project.The libraries are compatible with Ruby 1.9.3 and higher.

html5_validators - A gem/plugin for Rails 3, Rails 4, and Rails 5 that enables client-side validation using ActiveModel + HTML5 Form Validation

  •    Ruby

html5_validators is a gem/plugin for Rails 3+ that enables automatic client-side validation using ActiveModel + HTML5. Once you bundle this gem on your app, the gem will automatically translate your model validation code into HTML5 validation attributes on every form_for invocation unless you explicitly cancel it.

userstamp - This Rails plugin extends ActiveRecord::Base to add automatic updating of created_by and updated_by attributes of your models in much the same way that the ActiveRecord::Timestamp module updates created_(at/on) and updated_(at/on) attributes

  •    HTML

The Userstamp Plugin extends ActiveRecord::Base to add automatic updating of 'creator', 'updater', and 'deleter' attributes. It is based loosely on the ActiveRecord::Timestamp module. Two class methods (model_stamper and stampable) are implemented in this plugin. The model_stamper method is used in models that are responsible for creating, updating, or deleting other objects. The stampable method is used in models that are subject to being created, updated, or deleted by 'stampers'.

gitmodel - An ActiveModel-compliant persistence framework for Ruby that uses Git for versioning and remote syncing

  •    Ruby

GitModel is an ActiveModel-compliant persistence framework for Ruby that uses Git for versioning and remote syncing. GitModel persists Ruby objects using Git as a data storage engine. It's an ActiveModel implementation so it works stand-alone or in Rails 3 as a drop-in replacement for ActiveRecord or DataMapper.

simple_enum - Simple enum-like field support for ActiveModel (including validations and i18n)

  •    Ruby

Unobtrusive enum-like fields for ActiveRecord and Ruby, brings enums functionality to ActiveRecord and Mongoid models (built for Rails 4+). Note: a recent search on github for enum turned out, that there are many, many similar solutions. In fact starting with Rails 4.1, there's ActiveRecord::Enum which provides some of the functionality, but is IMHO pretty limited and too strict in the defaults it provides.

activerecord-postgis-adapter - ActiveRecord connection adapter for PostGIS, based on postgresql and rgeo

  •    Ruby

The activerecord-postgis-adapter provides access to features of the PostGIS geospatial database from ActiveRecord. It extends the standard postgresql adapter to provide support for the spatial data types and features added by the PostGIS extension. It uses the RGeo library to represent spatial data in Ruby. First, it provides spatial migrations. It extends the ActiveRecord migration syntax to support creating spatially-typed columns and spatial indexes. You can control the various PostGIS-provided attributes such as srid, dimension, and geographic vs geometric math.

activevalidators - Collection of ActiveModel/ActiveRecord validators

  •    Ruby

ActiveValidators is a collection of off-the-shelf and tested ActiveModel/ActiveRecord validations. ActiveValidators is cryptographically signed. Please make sure the gem you install hasn’t been tampered with.

awesome_nested_fields - Easy dynamic nested fields for Rails and jQuery applications.

  •    Ruby

In Rails, you can create forms that have fields from nested models. For example, if a person has many phone numbers, you can easily create a form that receives data from the person and from a fixed number of phones. However, when you want to allow the person to insert multiple, indefinite phones, you're in trouble: it's much harder than it should be. Well, not anymore. The accepts_nested_attributes_for is a method from Active Record that allows you to pass attributes of nested models directly to its parent, instead of instantiate each child object separately. In this case, Person gains a method called phones_attributes=, that accepts data for new and existing phones of a given person. The allow_destroy option enables us to also delete child objects. To know more about nested attributes, check out the ActiveRecord::NestedAttribute class.

parse_resource - A Ruby wrapper for's REST API

  •    Ruby

Unfortunately, I haven't been able to give this library the time it deserves. If you'd like to be a maintainer, please let me know. ParseResource makes it easy to interact with's REST API. It adheres to the ActiveRecord pattern. ParseResource is fully ActiveModel compliant, meaning you can use validations and Rails forms.

validates_url - URL Validation for Rails

  •    Ruby

This gem adds the capability of validating URLs to ActiveRecord and ActiveModel. The default error message is not a valid URL. You can pass the message: "my custom error" option to your validation to define your own, custom message.

active_record-acts_as - Simulate multi-table inheritance for activerecord models

  •    Ruby

Simulates multiple-table-inheritance (MTI) for ActiveRecord models. By default, ActiveRecord only supports single-table inheritance (STI). MTI gives you the benefits of STI but without having to place dozens of empty fields into a single table. Take a traditional e-commerce application for example: A product has common attributes (name, price, image ...), while each type of product has its own attributes: for example a pen has color, a book has author and publisher and so on. With multiple-table-inheritance you can have a products table with common columns and a separate table for each product type, i.e. a pens table with color column.

deep_pluck - Allow you to pluck attributes from nested associations without loading a bunch of records

  •    Ruby

Allow you to pluck deeply into nested associations without loading a bunch of records. Support Rails 3.2, 4.2, 5.0, 5.1, 5.2.

strongbox - Secures ActiveRecord attributes with public key encryption

  •    Ruby

Secures ActiveRecord attributes with public key encryption

activerecord-multi-tenant - Rails/ActiveRecord support for distributed multi-tenant databases like Postgres+Citus

  •    Ruby

ActiveRecord/Rails integration for multi-tenant databases, in particular the open-source Citus extension for PostgreSQL. Enables easy scale-out by adding the tenant context to your queries, enabling the database (e.g. Citus) to efficiently route queries to the right database node.

activerecord-session_store - Active Record's Session Store extracted from Rails

  •    Ruby

A session store backed by an Active Record class. A default class is provided, but any object duck-typing to an Active Record Session class with text session_id and data attributes is sufficient.To avoid your sessions table expanding without limit as it will store expired and potentially sensitive session data, it is strongly recommended in production environments to schedule the db:sessions:trim rake task to run daily. Running bin/rake db:sessions:trim will delete all sessions that have not been updated in the last 30 days. The 30 days cutoff can be changed using the SESSION_DAYS_TRIM_THRESHOLD environment variable.

mobility - Pluggable Ruby translation framework

  •    Ruby

Mobility is a gem for storing and retrieving translations as attributes on a class. These translations could be the content of blog posts, captions on images, tags on bookmarks, or anything else you might want to store in different languages. For examples of what Mobility can do, see the Companies using Mobility section below. Storage of translations is handled by customizable "backends" which encapsulate different storage strategies. The default way to store translations is to put them all in a set of two shared tables, but many alternatives are also supported, including translatable columns and model translation tables, as well as database-specific storage solutions such as json/jsonb and Hstore (for PostgreSQL).

smart_listing - Ruby on Rails data listing gem with built-in sorting, filtering and in-place editing

  •    Ruby

SmartListing helps creating AJAX-enabled lists of ActiveRecord collections or arrays with pagination, filtering, sorting and in-place editing. It will be placed in config/initializers/smart_listing.rb and will allow you to tweak some configuration settings like HTML classes and data attributes names.

bootstrap-rubygem - Bootstrap 4 rubygem for Rails / Sprockets / Hanami / etc

  •    Ruby

Bootstrap 4 ruby gem for Ruby on Rails (Sprockets) and Hanami (formerly Lotus). For Sass versions of Bootstrap 3 and 2 see bootstrap-sass instead.