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
9
votes
2 answers

Undefined method `tagged' for Formatter error after Rails 4 upgrade

I have upgraded from Rails 3.2 to Rails 4 by following the Ruby Screencast guide. My tests are running and the server starts, yet I receive an error when I send a request: ERROR NoMethodError: undefined method `tagged' for…
Mahoni
  • 7,088
  • 17
  • 58
  • 115
9
votes
2 answers

ActiveResource how to fetch a resource from a REST API that has a singular name?

I am trying to grab data from a third-party library that has an API that looks like: https://foo.com/user.json?username= I can't figure out how to force ActiveResource to use "user.json" instead of "users.json". Is it possible? I got it…
Logan Serman
  • 29,447
  • 27
  • 102
  • 141
8
votes
3 answers

Is there any ActiveResource like library for Java?

I know there are some ActiveResource Client libraries for Java, like RAPA and JactiveResource The question is: is there any easy way to create the Server Side of ActiveResource in Java? In RubyOnRails all you need to do is to use the Inherited…
Daniel Cukier
  • 11,502
  • 15
  • 68
  • 123
8
votes
2 answers

Active Resource responses, how to get them

I have an Active Resource that I query for data. It returns records, counts, whatever I ask for. eg: product = Product.find(123) The response headers supposedly contain a custom attribute, say "HTTP_PRODUCT_COUNT=20" and I would like to examine the…
David Lazar
  • 10,865
  • 3
  • 25
  • 38
8
votes
1 answer

Disable json root element in embedded objects on ActiveResource query

I got problem with unnecessary root element in embedded json object. Here is the cleaned sources: User model: class User < ActiveResource::Base self.format = :json self.element_name = "user" #... end Controller's action…
mind.debug
  • 283
  • 2
  • 10
8
votes
1 answer

Use underscores instead of dashes with ActiveResource XML (set :dasherize to false)

I am hitting all kinds of walls trying to stop rails from replacing XML underscores with dashes. I'm doing a post to a web service using ActiveResource. I have tried all kinds of variations of fixes for this, with results varying from rails…
slimchrisp
  • 101
  • 1
  • 3
8
votes
2 answers

Self documenting REST interface

I have a Rails based server running several REST services and a Rails based web UI that interacts with the server using ActiveResource. Same server is being used by other clients( e.g: mobile). I have to generate documentation for the REST…
Harish Shetty
  • 64,083
  • 21
  • 152
  • 198
7
votes
6 answers

debugging activeresource

I'm trying to get activeresource (on Rails 3.2) working with the Freebase API and I haven't had much luck yet. How can I debug rails to see what's going on and make sure the request is well formed? I think the suffixed .json is causing the failure…
ere
  • 1,739
  • 3
  • 19
  • 41
7
votes
1 answer

Getting ActiveModel::Callbacks to work with ActiveResource

I am trying to get ActiveModel::Callbacks to work with ActiveResource (specifically after_initialize) for a Rails 3 app, but I can't seem to get it to work. I don't get any errors, but the callback method is never executed. Here is a snippet of…
gmoniey
  • 7,975
  • 4
  • 27
  • 30
7
votes
4 answers

Having 'allocator undefined for Data' when saving with ActiveResource

What I am missing? I am trying to use a rest service for with Active resource, I have the following: class User < ActiveResource::Base self.site = "http://localhost:3000/" self.element_name = "users" self.format = :json end user = User.new( …
aletapool
  • 303
  • 3
  • 9
7
votes
2 answers

Multiple key/value pairs in HTTP POST where key is the same name

I'm working on an API that accepts data from remote clients, some of which where the key in an HTTP POST almost functions as an array. In english what this means is say I have a resource on my server called "class". A class in this sense, is the…
randombits
  • 47,058
  • 76
  • 251
  • 433
7
votes
9 answers

How do I view the HTTP response to an ActiveResource request?

I am trying to debug an ActiveResource call that is not working. What's the best way to view the HTTP response to the request ActiveResource is making?
Luke Francl
  • 31,028
  • 18
  • 69
  • 91
7
votes
2 answers

setting headers in active resource request

I have an Active Resource model that needs to set a header before posting/putting through save and update_attributes. The issue is that the header value needs to be different for each user, so it can't be set at the model level. I've seen examples…
d-coded
  • 413
  • 3
  • 9
6
votes
1 answer

Configuring ActiveResource to support OAuth2

I need to be able configure ActiveResource to connect with OAuth2 or basic authentication on a connection by connection basis. I have found a couple ways to configure ActiveResource with OAuth2, but they don't seem that elegant and don't lend…
Tom Rossi
  • 11,604
  • 5
  • 65
  • 96
6
votes
1 answer

rails 3.1.0 belongs_to ActiveResource no longer working

I am upgrading from rails 3.0.7 to 3.1 and am having trouble getting my tests to pass. The problem occurs when I try to use a stubbed active resource object in a factory. #employee.rb class Employee < ActiveResource::Base; end #task.rb class…
Aaron Renoir
  • 4,283
  • 1
  • 39
  • 61
1
2
3
23 24