CHANGELOG 2.0 KB
Newer Older
1 2
*SVN*

3 4 5 6 7 8 9 10 11
* Optimistic locking: raise ActiveResource::ResourceConflict on 409 Conflict response. [Jeremy Kemper]

    # Example controller action
    def update
      @person.save!
    rescue ActiveRecord::StaleObjectError
      render :xml => @person.reload.to_xml, :status => '409 Conflict'
    end

12 13 14 15 16 17
* Basic validation support [Rick Olson]

  Parses the xml response of ActiveRecord::Errors#to_xml with a similar interface to ActiveRecord::Errors.  
  
    render :xml => @person.errors.to_xml, :status => '400 Validation Error'

18 19 20 21 22 23 24 25 26
* Deep hashes are converted into collections of resources.  [Jeremy Kemper]
    Person.new :name => 'Bob',
               :address => { :id => 1, :city => 'Portland' },
               :contacts => [{ :id => 1 }, { :id => 2 }]
  Looks for Address and Contact resources and creates them if unavailable.
  So clients can fetch a complex resource in a single request if you e.g.
    render :xml => @person.to_xml(:include => [:address, :contacts])
  in your controller action.

27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
* Major updates [Rick Olson]

  * Add full support for find/create/update/destroy
  * Add support for specifying prefixes.
  * Allow overriding of element_name, collection_name, and primary key
  * Provide simpler HTTP mock interface for testing
  
    # rails routing code
    map.resources :posts do |post|
      post.resources :comments
    end
    
    # ActiveResources
    class Post < ActiveResource::Base
      self.site = "http://37s.sunrise.i:3000/"
    end

    class Comment < ActiveResource::Base
      self.site = "http://37s.sunrise.i:3000/posts/:post_id/"
    end
    
    @post     = Post.find 5
    @comments = Comment.find :all, :post_id => @post.id

    @comment  = Comment.new({:body => 'hello world'}, {:post_id => @post.id})
    @comment.save

54
* Base.site= accepts URIs. 200...400 are valid response codes. PUT and POST request bodies default to ''. [Jeremy Kemper]
J
Jeremy Kemper 已提交
55

56
* Initial checkin: object-oriented client for restful HTTP resources which follow the Rails convention. [DHH]