Git Product home page Git Product logo

trimmable's Introduction

Trimmable

Trimmable lib removes leading and trailing white spaces from the AR attribute values.

Installing

Trimmable gem

sudo gem install trimmable

Trimmable plugin

Run the following command in your Rails.root:

Rails 2.x
./script/plugin install [email protected]:viola/trimmable.git

Rails 3.x
./script/rails plugin install [email protected]:viola/trimmable.git

Usage

Model

class Post < ActiveRecord::Base
  validates_presence_of :title
  trimmable_attributes :title, :comments
end

Log output:

Started POST "/posts" for 127.0.0.1 at Sun Oct 31 20:30:59 -0400 2010
Processing by PostsController#create as HTML
Parameters: {"commit"=>"Create Post", "post"=>{"comments"=>"    new comment goes here      ", "title"=>"New title    "}, "authenticity_token"=>"Hjd4K8op5TAY7rL4k176tVehIr6eHzuR0vtNIRMlfRU=", "utf8"=>"✓"}
SQL (17.3ms)  INSERT INTO "posts" ("comments", "created_at", "title", "updated_at") VALUES ('new comment goes here', '2010-11-01 00:30:59.163811', 'New title', '2010-11-01 00:30:59.163811')
Redirected to http://localhost:3000/posts/12
Completed 302 Found in 40ms

trimmable's People

Contributors

viola avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.