This project is archived and is in readonly mode.

#6350 ✓stale
Nico Schottelius

errors[:base] is cleared when entering model

Reported by Nico Schottelius | January 31st, 2011 @ 01:46 PM


when using

@booking.errors.add(:base, "Only " + reservable_machines_count.to_s + " " + MachineType.find(type).name + "(s) available at the choosen date.")


@booking.errors[:base] << "Trying to book more " + typename + "s than existing."

in the controller, results in an empty array in the validation methods of
the booking model. I do not call errors.clear.

Example code:

# returns string from above (correctly) puts "Errors before calling model" + @booking.errors[:base].to_s ... respond_to do |format|

     format.html { redirect_to(@booking, :notice => 'Booking successfully created.') }
     format.xml  { render :xml => @booking, :status => :created, :location => @booking }
     # this line only contains the errors setup within the model, original ones are gone. (WRONG)
     puts "Errors after model" + @booking.errors[:base].to_s


validate :has_one_or_more_reservations

def has_one_or_more_reservations

  # this one is empty as well
  puts "printing errors : " + errors[:base].to_s
  errors[:base] << "No machine selected" if (reservations.nil? or reservations.empty?)


Actual codebase can be found on;a=summary.

Tested with rails 3.0.0 and 3.0.3.

Comments and changes to this ticket

  • Nico Schottelius

    Nico Schottelius January 31st, 2011 @ 01:48 PM

    According to
    this should work (and I think it used to work in rails2), according to the behaviour is not defined, though it would make sense if it works (again).

  • rails

    rails May 1st, 2011 @ 01:00 AM

    • State changed from “new” to “open”

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

  • rails

    rails May 1st, 2011 @ 01:00 AM

    • State changed from “open” to “stale”
  • af001

    af001 May 5th, 2011 @ 02:55 AM


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=""></a>

People watching this ticket