This project is archived and is in readonly mode.

#4169 ✓stale
Matthew Parker

ActiveResource::Base.save (PUT) doesn't clear out errors

Reported by Matthew Parker | March 13th, 2010 @ 10:51 PM | in 2.3.10

i've confirmed this bug in rails 2.3.5. here are the steps to reproduce:

first, create a standard rails app with a scaffolded "Author":

  # rails library
  # cd library
  # script/generate scaffold Author name:string
  # rake db:migrate

next, require that the "name" attribute on an author be present:

  # vim library/app/models/author.rb
  class Author < ActiveRecord::Base
    validates_presence_of :name
  end

start the app:

  
  # script/server

now, go into irb and create an ActiveResource::Base class that points to our library app:

  # irb
  >> require 'active_resource'
  >> class Author < ActiveResource::Base; self.site = 'http://localhost:3000'; end
  >> a = Author.new
  >> a.name = "moonmaster9000"
  >> a.save 
    ==> true
  >> a.name = nil
  >> a.save
    ==> false
  >> a.errors
    ==> #["can't be blank"]} ....
  >> a.name = "Matt Parker"
  >> a.save
    ==> true

In our library app, we've successfully updated the author record with the name "Matt Parker". At this point, I would expect a.errors to be empty again, and a.valid? to be true. Unfortunately, this is not the case:

  >> a.errors
    ==> #["can't be blank"]} ....
  >> a.valid? 
    ==> false

I'd be happy to look into fixing this bug; I do a lot of work with ActiveResource and have several gems that build on and extend ActiveResource (http://github.com/moonmaster9000) - however, I don't want to fix this bug if ARes is already undergoing a lot of changes for Rails 3, rendering any bug fix to a 2.3 branch obsolete.

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>

Attachments

Pages