Search code examples
ruby-on-railspostactiveresource

Customize the URL hit from ActiveResource


I have an application App2 to which I am sending a POST request from App1 using ActiveResource.

On the App1, I have

module App2
    class Iteeem # Purposely misspelled here
        def self.edit_item
            self.prefix "/api/editing_item/"
            post :item, {:property => {:value => 5665}}
        end
    end
end

It hits

http://app2.mydomain.com/api/editing_item/iteeems/item.xml 

(Now you know why I misspelt it)

But I want it to hit

http://app2.mydomain.com/api/editing_item/item.xml

Please advice.


Solution

  • Well, got it moments after I posted this! Just replace the trailing slash

    replace

    self.prefix "/api/editing_item/"
    

    with

    self.prefix "/api/editing_item"
    

    and add

    self.element_name ""
    

    Hope this helps someone...