Monday, January 16, 2012

Holy shit I've got a RESTful connection to a non-rails app with Rails... only a billion goddamn overrides of ActiveResource every GOD DAMN time I use the thing:

This finder produces: http://...spex...net/service/rest/catalog?appId=xxxxxx&method=getVersion

EtilizeProduct.find(:catalog, :params => {:appId => 'xxxxxx', :method => 'getVersion'})
 
Reports: 200 OK 157 (199.0ms) (Version 3.0) XML

I had to override element_path in ActiveResource::Base to do this:

  class << self
    def element_path(id, prefix_options = {}, query_options = nil)
      prefix_options, query_options = split_options(prefix_options) if query_options.nil?
      "#{prefix(prefix_options)}/#{id}#{query_string(query_options)}"
    end
  end

#Idea from: http://www.quarkruby.com/2008/3/11/consume-non-rails-style-rest-apis
This is here in case I need to do this again.

~Nic