This project is archived and is in readonly mode.

#2934 ✓committed
stefanpenner

association_collection#create acts as association_collection#create!

Reported by stefanpenner | July 21st, 2009 @ 09:13 PM

ActiveRecord has_many :through's association_collection#create seems to act as association_collection#create!, raising errors instead of merely building the AR object instance with the appropriate errors.

  #example
  http://github.com/stefanpenner/association_collection_create_bug/

Example

  #results in an error being raised.
  group.users.create(..with..invalid..user..attributes..)

Specs

  #Failing specs are included.
  rake

Workaround

  #Hackish Workaround.
  @user = group.users.create(..with..invalid..user..attributes..) rescue     User.build(..with..invalid..user..attributes..)

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>