Method: Redmine::SafeAttributes#safe_attribute_names
- Defined in:
- lib/redmine/safe_attributes.rb
#safe_attribute_names(user = nil) ⇒ Object
Returns an array that can be safely set by user or current user
Example:
book.safe_attributes # => ['title', 'pages']
book.safe_attributes(book.) # => ['title', 'pages', 'isbn']
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/redmine/safe_attributes.rb', line 53 def safe_attribute_names(user=nil) return @safe_attribute_names if @safe_attribute_names && user.nil? names = [] self.class.safe_attributes.collect do |attrs, | if [:if].nil? || [:if].call(self, user || User.current) names += attrs.collect(&:to_s) end end names.uniq! @safe_attribute_names = names if user.nil? names end |