尝试这个
Class ABC
require "rubygems"
#This code block just makes sure not to append .json to the call
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)}#{collection_name}/#{id}#{query_string(query_options)}"
end
def collection_path(prefix_options = {}, query_options = nil)
prefix_options, query_options = split_options(prefix_options) if query_options.nil?
"#{prefix(prefix_options)}#{collection_name}#{query_string(query_options)}"
end
end
#Ur site url
ActiveResource::Base.site = 'http://aaa:8080/'
self.format = :json
self.collection_name= "/company/"
def self.find(company_id, id)
x = superclass.find(:all, :from => '/company/%s/users/%s' %[company_id,id])
x
end
end
在你的控制器中,你会做
@test=ABC.find(params[:customer_id],params[:id])
这将从 api 返回数据。请让我知道这对你有没有用。