Emmek on Rails
2009-Oct-23 13:24 UTC
Sanitize html with :before_save depending on logged in user
I woud like to sanitize attributes (with ''sanitize" gem) but
unless the
model is being saved by admin. (Suppose this model doesn''t have any
relationship with user model)
# In model.rb:
:before_save set_html_plain
def set_html_plain
self.body = Sanitize.clean(self.body)
end
Two questions:
1) How can I check here if saving process has been initialized by
specified, logged in user (admin)?
2) What is the best way to abstract these operations to use them easily
on multiple models?
--
Posted via http://www.ruby-forum.com/.
