It happened to me when my object was new and unsaved, when I typed build.
buildassigns plan_id, and if @planid is zero, then your ticket plan_idwill be zero. Since it builddoes not check and does not save, you will not recognize it later.
, , , . :
@plan.tickets << Ticket.new(...)
@plan.save