CHANGELOG 9.3 KB
Newer Older
1 2
*Edge*

3 4
* Fixed problems with the logger used if the logging string included %'s [#840 state:resolved] (Jamis Buck)

5 6 7
* Fixed Base#exists? to check status code as integer [#299 state:resolved] (Wes Oldenbeuving)


8
*2.1.0 (May 31st, 2008)*
J
Jeremy Kemper 已提交
9

10 11
* Fixed response logging to use length instead of the entire thing (seangeo) [#27]

12 13
* Fixed that to_param should be used and honored instead of hardcoding the id #11406 [gspiers]

P
Pratik Naik 已提交
14 15
* Improve documentation. [Radar, Jan De Poorter, chuyeow, xaviershay, danger, miloops, Xavier Noria,  Sunny Ripert]

16 17
* Use HEAD instead of GET in exists? [bscofield]

18 19
* Fix small documentation typo.  Closes #10670 [l.guidi]

20 21
* find_or_create_resource_for handles module nesting.  #10646 [xavier]

22 23
* Allow setting ActiveResource::Base#format before #site.  [rick]

24 25
* Support agnostic formats when calling custom methods.  Closes #10635 [joerichsen]

26 27
* Document custom methods.  #10589 [Cheah Chu Yeow]

J
Jeremy Kemper 已提交
28 29 30
* Ruby 1.9 compatibility.  [Jeremy Kemper]


31
*2.0.2* (December 16th, 2007)
32

33 34
* Added more specific exceptions for 400, 401, and 403 (all descending from ClientError so existing rescues will work) #10326 [trek]

35 36 37
* Correct empty response handling.  #10445 [seangeo]


D
David Heinemeier Hansson 已提交
38
*2.0.1* (December 7th, 2007)
D
David Heinemeier Hansson 已提交
39

40 41
* Don't cache net/http object so that ActiveResource is more thread-safe.  Closes #10142 [kou]

42 43
* Update XML documentation examples to include explicit type attributes. Closes #9754 [hasmanyjosh]

44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
* Added one-off declarations of mock behavior [DHH]. Example:

    Before:
      ActiveResource::HttpMock.respond_to do |mock|
        mock.get "/people/1.xml", {}, "<person><name>David</name></person>"
      end
      
    Now:
      ActiveResource::HttpMock.respond_to.get "/people/1.xml", {}, "<person><name>David</name></person>"

* Added ActiveResource.format= which defaults to :xml but can also be set to :json [DHH]. Example:

    class Person < ActiveResource::Base
      self.site   = "http://app/"
      self.format = :json
    end
    
    person = Person.find(1) # => GET http://app/people/1.json
    person.name = "David"
    person.save             # => PUT http://app/people/1.json {name: "David"}
    
    Person.format = :xml
    person.name = "Mary"
    person.save             # => PUT http://app/people/1.json <person><name>Mary</name></person>    

69 70
* Fix reload error when path prefix is used.  #8727 [Ian Warshak]

71 72
* Remove ActiveResource::Struct because it hasn't proven very useful. Creating a new ActiveResource::Base subclass is often less code and always clearer.  #8612 [Josh Peek]

T
 
Tobias Lütke 已提交
73 74
* Fix query methods on resources. [Cody Fauser]

75 76
* pass the prefix_options to the instantiated record when using find without a specific id. Closes #8544 [alloy]

77 78
* Recognize and raise an exception on 405 Method Not Allowed responses.  #7692 [Josh Peek]

79 80 81 82
* Handle string and symbol param keys when splitting params into prefix params and query params.

    Comment.find(:all, :params => { :article_id => 5, :page => 2 }) or Comment.find(:all, :params => { 'article_id' => 5, :page => 2 })

83 84 85 86 87 88 89 90 91
* Added find-one with symbol [DHH]. Example: Person.find(:one, :from => :leader) # => GET /people/leader.xml

* BACKWARDS INCOMPATIBLE: Changed the finder API to be more extensible with :params and more strict usage of scopes [DHH]. Changes:

    Person.find(:all, :title => "CEO")      ...becomes: Person.find(:all, :params => { :title => "CEO" })
    Person.find(:managers)                  ...becomes: Person.find(:all, :from => :managers)
    Person.find("/companies/1/manager.xml") ...becomes: Person.find(:one, :from => "/companies/1/manager.xml")

* Add support for setting custom headers per Active Resource model [Rick]
92 93

  class Project
94
    headers['X-Token'] = 'foo'
95 96 97 98 99
  end
  
  # makes the GET request with the custom X-Token header
  Project.find(:all)

100 101 102 103 104 105
* Added find-by-path options to ActiveResource::Base.find [DHH]. Examples:

    employees = Person.find(:all, :from => "/companies/1/people.xml") # => GET /companies/1/people.xml
    manager   = Person.find("/companies/1/manager.xml")               # => GET /companies/1/manager.xml


106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
* Added support for using classes from within a single nested module [DHH]. Example:

    module Highrise
      class Note < ActiveResource::Base
        self.site = "http://37s.sunrise.i:3000"
      end

      class Comment < ActiveResource::Base
        self.site = "http://37s.sunrise.i:3000"
      end
    end

  assert_kind_of Highrise::Comment, Note.find(1).comments.first
    

121 122 123 124 125 126 127 128 129 130 131
* Added load_attributes_from_response as a way of loading attributes from other responses than just create [DHH]

    class Highrise::Task < ActiveResource::Base
      def complete
        load_attributes_from_response(post(:complete))
      end
    end

  ...will set "done_at" when complete is called.


132 133 134 135 136
* Added support for calling custom methods #6979 [rwdaigle]

    Person.find(:managers)    # => GET /people/managers.xml
    Kase.find(1).post(:close) # => POST /kases/1/close.xml

137 138 139 140 141 142 143
* Remove explicit prefix_options parameter for ActiveResource::Base#initialize. [Rick]
  ActiveResource splits the prefix_options from it automatically.

* Allow ActiveResource::Base.delete with custom prefix. [Rick]

* Add ActiveResource::Base#dup [Rick]

144 145 146 147 148 149
* Fixed constant warning when fetching the same object multiple times [DHH]

* Added that saves which get a body response (and not just a 201) will use that response to update themselves [DHH]

* Disregard namespaces from the default element name, so Highrise::Person will just try to fetch from "/people", not "/highrise/people" [DHH]

150 151
* Allow array and hash query parameters.  #7756 [Greg Spurrier]

152 153
* Loading a resource preserves its prefix_options.  #7353 [Ryan Daigle]

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

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

158 159
* Interpret 422 Unprocessable Entity as ResourceInvalid.  #7097 [dkubb]

160 161
* Mega documentation patches. #7025, #7069 [rwdaigle]

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

164 165 166 167
* Query string support.  [untext, Jeremy Kemper]
    # GET /forums/1/topics.xml?sort=created_at
    Topic.find(:all, :forum_id => 1, :sort => 'created_at')

168 169
* 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]

170
* Allow subclassed resources to share the site info [Rick, Jeremy Kemper]
171
d
172 173 174
    class BeastResource < ActiveResource::Base
      self.site = 'http://beast.caboo.se'
    end
175

176 177 178 179
    class Forum < BeastResource
      # taken from BeastResource
      # self.site = 'http://beast.caboo.se'
    end
180

181
    class Topic < BeastResource
182
      self.site += '/forums/:forum_id'
183 184
    end

185 186
* Fix issues with ActiveResource collection handling.  Closes #6291. [bmilekic]

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

189 190
* Add basic logging support for logging outgoing requests. [Jamis Buck]

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

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

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

197 198 199
* 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.

200 201 202 203 204 205 206 207 208
* 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

209 210 211 212 213 214
* 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'

215 216 217 218 219 220 221 222 223
* 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.

224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250
* 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

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

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