Forum: Ruby on Rails Removing empty fields before saving

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Vapor .. (Guest)
on 2009-04-01 23:06
When I save data, form submits some empty (but not null) data.
How can I remove that?

Thanks.
Philip H. (Guest)
on 2009-04-01 23:12
(Received via mailing list)
> When I save data, form submits some empty (but not null) data.
> How can I remove that?

Write a before_save method on your model that looks at each attribute
and if it's a blank string set it to nil.  I can't think of the name,
but someone wrote a plugin that does exactly this.
Sijo k. (Guest)
on 2009-04-03 15:15
plugin-

StripAttributes
This topic is locked and can not be replied to.