Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

[PATCH] add strip_attributes support to ActiveModel and Active Record

#3130

Added support for ActiveModel#strip_attributes and ActiveRecord::Base.strip_attributes!

ActiveModel#strip_attributes removes leading and trailing
white spaces from all applicable attributes.

ActiveRecord::Base.strip_attributes! adds a before_validation
filter to your class which calls ActiveModel#strip_attributes.

Both support :only and :except as options.

This is useful for cleaning up form-inputted attributes.

This patch has been rebased for master.

Reported by Josh Sharpe · September 1st, 2009 @ 03:22 PM

State: invalid
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. CancelProfileIsBroken
    CancelProfileIsBroken
    • Tag changed from 3.0, activemodel, activerecord, strip_attribtutes to 3.0, activemodel, activerecord, bugmash, strip_attribtutes

    September 25th, 2009 @ 12:36 PM

  2. Blue Box Jesse
    Blue Box Jesse

    BugMash: +1

    Applies to master cleanly. Do not see any related errors as a result of the patch.

    Good idea / useful tool.

    September 27th, 2009 @ 01:16 AM

  3. sr.iniv.t
    sr.iniv.t

    +1 verified.

    Great idea - i have run into situations where we needed this kind of behavior would have been helpful. The patch applies without any problems and all tests pass.

    September 27th, 2009 @ 07:57 AM

  4. CancelProfileIsBroken
    CancelProfileIsBroken
    • Tag changed from 3.0, activemodel, activerecord, bugmash, strip_attribtutes to 3.0, activemodel, activerecord, bugmash-review, strip_attribtutes

    September 27th, 2009 @ 11:57 AM

  5. Rizwan Reza
    Rizwan Reza
    • Tag changed from 3.0, activemodel, activerecord, bugmash-review, strip_attribtutes to 3.0, activemodel, activerecord, bugmash, strip_attribtutes

    The patch doesn't apply to master anymore.

    January 18th, 2010 @ 02:06 PM

  6. Prem Sichanugrist (sikachu)
  7. Prem Sichanugrist (sikachu)
    Prem Sichanugrist (sikachu)
    • Tag changed from 3.0, activemodel, activerecord, bugmash, strip_attribtutes to 3.0, activemodel, activerecord, bugmash, bugmash-review, review, strip_attribtutes

    January 20th, 2010 @ 06:43 AM

  8. Prem Sichanugrist (sikachu)
    Prem Sichanugrist (sikachu)

    @Josh Sharpe

    After I have discuss your addition in #rails-contrib, I can't really find a good use case for this method. So, I think this feature would be nice to be made as a plugin instead. If there're enough user using it, then it can be merged into core later.

    Thank you :)

    January 20th, 2010 @ 09:23 AM

  9. Yehuda Katz (wycats)
    Yehuda Katz (wycats)
    • State changed from new to invalid

    January 20th, 2010 @ 09:26 AM

  10. Rizwan Reza
    Rizwan Reza
    • Tag changed from 3.0, activemodel, activerecord, bugmash, bugmash-review, review, strip_attribtutes to 3.0, activemodel, activerecord, bugmash, review, strip_attribtutes

    May 15th, 2010 @ 06:45 PM