Example Case- How add filter to strip all html tags(this code not works, just psedocode for want i need to get):
class Person < ActiveRecord::Base
validates :name, :presence => true
#psedocode:
**filters:name,:strip_tags=>true**
end
Example Case- How add filter to strip all html tags(this code not works, just psedocode for want i need to get):
class Person < ActiveRecord::Base
validates :name, :presence => true
#psedocode:
**filters:name,:strip_tags=>true**
end
Yes, ActiveRecord has a bunch of callbacks that you can tap into such as before_save, before_validation, etc. You can do something like this:
class Person < ActiveRecord::Base
before_save :strip_tags
private
def strip_tags
self.name = name.gsub(TAGS, '')
end
end
More information in the Rails guide on ActiveRecord callbacks