Karlis
Karlis

Reputation: 1501

Rails GET from json data ActiveResource

I have small school project.

My roommate create an application which simulates a burger order system. But I had to create an delivery service application.

Our idea was like this:

He gives me JSON data from his order page and I read this data and display in my admin page.

This is the link where JSON data is parsed https://eburger-appzz.rhcloud.com/public-orders

How can I display this data in my application?

I tried to connect to it with ActiveResource like this ->

self.site="http://eburger-appzz.rhcloud.com/public-orders"

but I can't get it to work.

Any suggestions, what would be the best way to GET this data from server?

Upvotes: 2

Views: 371

Answers (1)

ch4nd4n
ch4nd4n

Reputation: 4197

I quickly tried out the URI that you have given and was able to get it working with following code.

class PublicOrder < ActiveResource::Base
  self.site="http://eburger-appzz.rhcloud.com/"
  self.element_name = "public-orders"
end

and to fetch all public orders

public_orders = PublicOrder.find(:all)

listed orders.

BTW we have been using ActiveResource for a while now and to be able to use ActiveResource, consider implementing REST service as per their philosophy

Upvotes: 3

Related Questions