Module: SneakySave

Defined in:
lib/sneaky-save.rb

Overview

– Copyright © 2011 PartyEarth LLC [email protected] ++

Instance Method Summary collapse

Instance Method Details

#sneaky_savefalse, true

Note:
  • Does not reload updated record by default.

  • Does not save associated collections.

  • Saves only belongs_to relations.

Saves the record without running callbacks/validations. Returns true if the record is changed.

Returns:

  • (false, true)


14
15
16
17
18
19
20
# File 'lib/sneaky-save.rb', line 14

def sneaky_save
  begin
    sneaky_create_or_update
  rescue ActiveRecord::StatementInvalid
    false
  end
end

#sneaky_save!true

Saves record without running callbacks/validations.

Returns:

  • (true)

    if save was successful.

Raises:

  • (ActiveRecord::StatementInvalid)

    if saving failed.

See Also:

  • ActiveRecord::Base#sneaky_save


26
27
28
# File 'lib/sneaky-save.rb', line 26

def sneaky_save!
  sneaky_create_or_update
end