Closed bloudermilk closed 14 years ago
ah ok i think i c what the problem is. thanks for reporting it! i'll fix it this weekend.
No problem! Dupe has a been a huge help so far in my attempt to TDDize one of my APIs
hi brendan,
i'm having trouble duplicating this problem (i'm using Dupe 0.5.1):
>> require 'dupe' => true >> class Book < ActiveResource::Base; self.site='/api/vi'; end => "/api/vi" >> Dupe.define :book => #<Dupe::Model:0x198aa20 @id_sequence=#<Sequence:0x198a9e4 @current_value=1, @transformer=nil>, name:book, schema#<Dupe::Model::Schema:0x198a9f8 @after_create_callbacks=[], @attribute_templates={}> >> Book.site => #<URI::Generic:0x198c6f4 URL:/api/vi/> >> Book.prefix => "/api/vi/" >> Dupe.create :book => <#Duped::Book id=1> >> Book.find 1 => #<Book:0x1967f34 @attributes={"id"=>1}, prefix_options{} >> puts Dupe.network.log.pretty_print Logged Requests: Request: GET /api/vi/books/1.xml Response: <?xml version="1.0" encoding="UTF-8"?> <book> <id type="integer">1</id> </book>
Ahhh, my mistake. This came from the fact that I was including the full url path in a custom .find()
call like:
Book.find(:all, :from => "http://hostname/author/#{author_id}/books.xml")
Once I formatted that call like so:
Book.find(:all, :from => "/author/#{author_id}/books.xml")
it worked.
Thanks and sorry for wasting your time!
When my ActiveResource objects are configured to use non-root URLs like
http://host/api/v1
, Dupe doesn't know how to create the standard CRUD intercepts. It knows to look at at the right URL when.find()
ing, but returns this error:This is easily solved on my side by simply removing everything after
http://host/
, but it would be nice if there was built in support for this.