Returns a hash of all the attributes with their names as keys and clones of their objects as values.
Source Code
# File active_record/base.rb, line 2126 def attributes(options = nil) attributes = clone_attributes :read_attribute if options.nil? attributes else if except = options[:except] except = Array(except).collect { |attribute| attribute.to_s } except.each { |attribute_name| attributes.delete(attribute_name) } attributes elsif only = options[:only] only = Array(only).collect { |attribute| attribute.to_s } attributes.delete_if { |key, value| !only.include?(key) } attributes else raise ArgumentError, "Options does not specify :except or :only (#{options.keys.inspect})" end end end
<code/>and<pre/>for code samples.