CHANGELOG 3.9 KB
Newer Older
1 2
*SVN*

3 4
* Allow array and hash query parameters.  #7756 [Greg Spurrier]

5 6
* Loading a resource preserves its prefix_options.  #7353 [Ryan Daigle]

7 8
* Carry over the convenience of #create from ActiveRecord.  Closes #7340.  [Ryan Daigle]

9 10
* Increase ActiveResource::Base test coverage.  Closes #7173, #7174 [Rich Collins]

11 12
* Interpret 422 Unprocessable Entity as ResourceInvalid.  #7097 [dkubb]

13 14
* Mega documentation patches. #7025, #7069 [rwdaigle]

15 16
* Base.exists?(id, options) and Base#exists? check whether the resource is found.  #6970 [rwdaigle]

17 18 19 20
* Query string support.  [untext, Jeremy Kemper]
    # GET /forums/1/topics.xml?sort=created_at
    Topic.find(:all, :forum_id => 1, :sort => 'created_at')

21 22
* Base#==, eql?, and hash methods. == returns true if its argument is identical to self or if it's an instance of the same class, is not new?, and has the same id. eql? is an alias for ==. hash delegates to id.  [Jeremy Kemper]

23
* Allow subclassed resources to share the site info [Rick, Jeremy Kemper]
24 25 26 27

    class BeastResource < ActiveResource::Base
      self.site = 'http://beast.caboo.se'
    end
28

29 30 31 32
    class Forum < BeastResource
      # taken from BeastResource
      # self.site = 'http://beast.caboo.se'
    end
33

34
    class Topic < BeastResource
35
      self.site += '/forums/:forum_id'
36 37
    end

38 39
* Fix issues with ActiveResource collection handling.  Closes #6291. [bmilekic]

40 41
* Use attr_accessor_with_default to dry up attribute initialization. References #6538. [Stuart Halloway]

42 43
* Add basic logging support for logging outgoing requests. [Jamis Buck]

44 45
* Add Base.delete for deleting resources without having to instantiate them first. [Jamis Buck]

46 47
* Make #save behavior mimic AR::Base#save (true on success, false on failure). [Jamis Buck]

48 49
* Add Basic HTTP Authentication to ActiveResource (closes #6305). [jonathan]

50 51 52
* Extracted #id_from_response as an entry point for customizing how a created resource gets its own ID.
  By default, it extracts from the Location response header.

53 54 55 56 57 58 59 60 61
* 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

62 63 64 65 66 67
* 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'

68 69 70 71 72 73 74 75 76
* 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.

77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
* 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

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

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