Skip to content

Instantly share code, notes, and snippets.

@moserrya
Last active August 29, 2015 14:09
Show Gist options
  • Save moserrya/c276d5d8a93f8a54bfee to your computer and use it in GitHub Desktop.
Save moserrya/c276d5d8a93f8a54bfee to your computer and use it in GitHub Desktop.

Revisions

  1. moserrya revised this gist Nov 9, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -4,5 +4,5 @@
    item.update_attributes!(state: "sold")
    end

    # item.update_attributes! fails a validation, which we rescue
    # item.update_attributes! fails a validation, which we rescue. new feeling that we created is rightly rolled back
    item.save #saves the feelings record that was rolled back as part of our transaction!
  2. moserrya revised this gist Nov 9, 2014. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,8 @@
    item = Item.find 328
    item.transaction do
    item.feelings.create!(size: 'huge')
    item.update_attributes!(state: "sold")
    end

    # item.update_attributes! fails a validation, which we rescue
    item.save #saves the feelings record that was rolled back as part of our transaction!
  3. moserrya created this gist Nov 9, 2014.
    3 changes: 3 additions & 0 deletions gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    item = Item.find 328
    item.transaction do
    item.feelings.create!(size: 'huge')