Skip to content

Instantly share code, notes, and snippets.

@solnic
Created September 11, 2010 09:32
Show Gist options
  • Select an option

  • Save solnic/575030 to your computer and use it in GitHub Desktop.

Select an option

Save solnic/575030 to your computer and use it in GitHub Desktop.
# Role.validates_presence_of :name
user = User.get(1)
user.attributes = { :roles => [{:name => 'foo'}, {:name => nil}] }
user.save # returns false
user.valid? # returns true
# you cannot validate roles here in before :valid? hook b/c it's not called in the example above!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment