Skip to content

Instantly share code, notes, and snippets.

@matthodan
Created December 1, 2010 01:04
Show Gist options
  • Save matthodan/722751 to your computer and use it in GitHub Desktop.
Save matthodan/722751 to your computer and use it in GitHub Desktop.

Revisions

  1. @invalid-email-address Anonymous revised this gist Dec 1, 2010. 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
    @@ -3,7 +3,7 @@ class User < ActiveRecord:Base

    private
    def user_is_happy_and_broke
    if self.state_of_mind == 'happy' && self.fiscal_status == 'broke'
    if self.state_of_mind != 'happy' || self.fiscal_status != 'broke'
    errors.add :user_not_happy_and_broke, 'User must be happy and broke to continue'
    end
    end
  2. @invalid-email-address Anonymous created this gist Dec 1, 2010.
    10 changes: 10 additions & 0 deletions gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    class User < ActiveRecord:Base
    validate :user_is_happy_and_broke

    private
    def user_is_happy_and_broke
    if self.state_of_mind == 'happy' && self.fiscal_status == 'broke'
    errors.add :user_not_happy_and_broke, 'User must be happy and broke to continue'
    end
    end
    end