Module: ActiveRecord::AttributeMethods::ClassMethods

Defined in:
lib/brick/extensions.rb

Instance Method Summary collapse

Instance Method Details

#_brick_dangerous_attribute_method?Object



566
# File 'lib/brick/extensions.rb', line 566

alias _brick_dangerous_attribute_method? dangerous_attribute_method?

#dangerous_attribute_method?(name) ⇒ Boolean

Bypass the error “ActiveRecord::DangerousAttributeError” if this object comes from a view. (Allows for column names such as ‘attribute’, ‘delete’, and ‘update’ to still work.)

Returns:

  • (Boolean)


569
570
571
572
573
574
575
576
577
# File 'lib/brick/extensions.rb', line 569

def dangerous_attribute_method?(name)
  if (is_dangerous = _brick_dangerous_attribute_method?(name)) && is_view?
    if column_names.include?(name.to_s)
      puts "WARNING:  Column \"#{name}\" in view #{table_name} conflicts with a reserved ActiveRecord method name."
    end
    return false
  end
  is_dangerous
end