Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# The models
class User < ActiveRecord::Base
has_many :things
accepts_nested_attributes_for :things
class Thing < ActiveRecord::Base
belongs_to :user
validates_presence_of :user_id
validates_presence_of :name # For clarity below
# Trying to create a new user with a new thing
u = => [{:name => 'thing'}]) #=> false
u.errors.full_messages #=> ["Things user can't be blank"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment