Module: ActiveRecord::AttributeMethods::ClassMethods

Defined in:
lib/brick/extensions.rb

Instance Method Summary collapse

Instance Method Details

#_brick_dangerous_attribute_method?Object



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

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)


493
494
495
496
497
498
499
500
501
# File 'lib/brick/extensions.rb', line 493

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