Questions tagged [activeresource]

ActiveResource is the main class for mapping RESTful resources as models in a Rails application

Active Resource objects represent your RESTful resources as manipulatable Ruby objects. To map resources to Ruby objects, Active Resource only needs a class name that corresponds to the resource name (e.g., the class Person maps to the resources people, very similarly to Active Record) and a site value, which holds the URI of the resources.

355 questions
3
votes
2 answers

How to get past [@attributes] in SimpleXMLElement?

The goal: Using PHP/CodeIgniter, I need to get a list of users and their custom field names and values in a usable array. If I can just get to the items, I can do what I need. Please see OUTPUT with notes for "// <<< " so you can see where I'm…
glassfish
  • 721
  • 1
  • 9
  • 14
3
votes
1 answer

ActiveResource: specify retry?

I'm using ActiveResource for long-running import and synchronization jobs. Is there a way to specify retries for failed requests? I want to avoid ugly begin/rescue/retry constructs around each and every ActiveResource request.
Ortwin Gentz
  • 52,648
  • 24
  • 135
  • 213
3
votes
1 answer

Rails 3.2, activeresource and certificate authentication

I'm writing to ask for an example of use of the active resource with certificate authentication. The documentation found on http://apidock.com/rails/ActiveResource/Base does not provide examples. I have two rails application that need to…
2
votes
1 answer

Supplying credentials to web service via ActiveResource

This is my first attempt at writing a Rails app to consume an external web service. I have done some basic experimentation retrieving some records from another rails app via ActiveResource which worked pretty well, but in this instance I am trying…
Still Real
  • 401
  • 1
  • 4
  • 3
2
votes
1 answer

ActiveResource vs HTTParty

I'm moving our primary datastore away from ActiveRecord, and instead the data will be accessible through a REST api as JSON. Should I use ActiveResource or HTTParty to access the data? It's primarily going to be read-only for view rendering.
MrEvil
  • 7,785
  • 7
  • 36
  • 36
2
votes
0 answers

RoR ActiveResource nested resources : Difference between 3.2.1 and 3.0.7

I have two simple models, clown.rb and funny_hat.rb. ARes 3.0.7 clown = Clown.new({:funnyHats => [{ :id => "123" },{ :id => "456" }]}) p clown #[#
Mark Peterson
  • 570
  • 5
  • 19
2
votes
2 answers

Ruby/Rails - consume webservice with ActiveResource

just getting started with Rails, I would like to consume a webservice (using ActiveResource) that has the following endpoint: GET /user?some_header=XYZ This is my ActiveResource Class: class User < ActiveResource::Base self.site = "url" …
2
votes
2 answers

rails 3 REST: activeresource destroy validation

Hi all I'm using active_resource and have next question. sometimes there is destroy validation needed Example def destroy if @user.destroy head :ok else respond_with(@user) end end user model can't be deleted…
Fivell
  • 11,829
  • 3
  • 61
  • 99
2
votes
1 answer

Rails 3.1.3 REST : Can't retrieve errors from activeresource side (json serializer)

I have Server working with active models (not active record), and client side with activeresource . For example server side controller have such code ... def update if @supplier.update_attributes(params[:supplier]) …
Fivell
  • 11,829
  • 3
  • 61
  • 99
2
votes
2 answers

Set site/user fields in ActiveResource

I am building a sinatra app that will use Highrise CRM gem to access Highrise data. This gem is based on ActiveResource class. I want to set site, user fields for every request. I followed suggestion posted here - Is it thread safe to set Active…
2
votes
0 answers

How can I build a complex polymorphic association which includes ActiveResource classes?

I'm attempting to build a diverse tournament management system which allows multiple types of tournament bracket backends. The goal is to provide a very simple option for the tournament bracket backend (here, PlasTournament) and the possibility of…
2
votes
2 answers

ActiveResource pagination

What would be the best way to approach pagination over an API with active resource? I'm building the API and the app consuming the API so I need both ends of the equation. I've seen people setting headers for what page they want in ActiveResource…
Robert Ross
  • 1,895
  • 2
  • 23
  • 32
2
votes
3 answers

ActiveResource Caching

How would you cache an ActiveResource model? Preferably in memcached. Right now it's pulling a model from my REST API fine but it pulls dozens of records each time. Would be best to cache them.
Robert Ross
  • 1,895
  • 2
  • 23
  • 32
2
votes
1 answer

Resources to learn ActiveResource in Rails 3 - in pragmatic way

Can somebody point me to resources that will help me understand A to Z of ActiveResource in Rails 3? I tried looking out for books and articles in vain :( Pointers to any open-sourced project that I can play with should also be of help. Your help is…
karthiks
  • 7,049
  • 7
  • 47
  • 62
2
votes
2 answers

activeresource error status and response body

I am making an activeresource call to a service, and I'd like some custom error messages as feedback. I have some validations that aren't normal model validations, so I can't just return @object.errors. So, for instance, one of my validations is…
brad
  • 31,987
  • 28
  • 102
  • 155