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

ActiveResource should ignore root xml element

I am trying to conect to REST service like this class Node < ActiveResource::Base self.site = "http://www.openstreetmap.org/api/0.6/" self.element_name = "node" self.collection_name = "node" self.format = ActiveResource::Formats::XmlFormat…
gorn
  • 5,042
  • 7
  • 31
  • 46
2
votes
3 answers

Using ActiveResource without Rails

Hi I'm developing a Rails application that exposes some methods via ActiveResource. I want to access these resources through a simple remote ruby script. I want to know if it's possible use ActiveResource without Rails .
Lucas
  • 3,059
  • 5
  • 33
  • 48
2
votes
1 answer

Convert CamelCase xml/json to ruby named attributes with ActiveResource

I'm using ActiveResource to consume a REST service. The xml from the service looks like: Kevin Berridge ActiveResource parses this just fine, but it uses the names verbatim. So…
Kevin Berridge
  • 6,251
  • 6
  • 41
  • 42
2
votes
1 answer

How Do I Get Response Headers From ActiveResource?

I'm using ActiveResource 4.0, and I need to get pagination working. I've set the response headers on the server end, but I cannot read them on the client end. I'm using this great blog…
Petercopter
  • 1,218
  • 11
  • 16
2
votes
1 answer

How can I upload files to Redmine via ActiveResource / REST API?

I am trying to batch-upload images to Redmine and link them each to a certain wiki pages. The docs (Rest_api, Using the REST API with Ruby) mention some aspects, but the examples fail in various ways. I also tried to derive ideas from the source -…
user569825
  • 2,369
  • 1
  • 25
  • 45
2
votes
1 answer

Rest-style API design - merging models into one resource?

My question is about when it's OK to merge separate models into one single REST resource and whether this leads to tricky and difficult to work with design, down the line. Let's say I have a movie streaming service and users can only watch movie…
Alexandr Kurilin
  • 7,685
  • 6
  • 48
  • 76
2
votes
2 answers

Changing an instance variable within dynamic method (dynamic resource using ActiveResource)

I am using dynamic dispatch to define several class methods in a class that inherits from ActiveResource. class Invoice < ActiveResource::Base self.site = 'http://localhost:8080/' def self.define(method) define_singleton_method(method) do…
2
votes
0 answers

ActiveResource Update Operation :: Can't mass-assign protected attributes: created_at, id, updated_at

When I try to update and save ActiveResource I am getting following error. on console > m = Machine.first => #"2013-04-22T09:13:56Z", "id"=>1, "name"=>"laptop", "updated_at"=>"2013-04-22T09:13:56Z"},…
Amit Patel
  • 15,609
  • 18
  • 68
  • 106
2
votes
1 answer

ActiveMessaging, ActiveResources, or Ruby XMLRPC

I have a simple jruby+swt based client that collects data on an occasionally connected PC. Now I need to push those records to the server (Rails 2.3). Should I use ActiveMessaging, ActiveResources or Ruby XMLRPC. This is my current…
jrhicks
  • 14,759
  • 9
  • 42
  • 57
2
votes
2 answers

How Do I Authenticate to ActiveResource to Avoid the InvalidAuthenticityToken Response?

I created a Rails application normally. Then created the scaffold for an event class. Then tried the following code. When run it complains about a InvalidAuthenticityToken when the destroy method is executed. How do I authenticate to avoid this…
David Medinets
  • 5,160
  • 3
  • 29
  • 42
2
votes
2 answers

Rails, nested attributes, can't mass assign error

I have two models on server: Feed class Feed < ActiveRecord::Base attr_accessible :name belongs_to :broadcasts end Broadcast class Broadcast < ActiveRecord::Base validates_presence_of :content attr_accessible :content, feeds,…
George
  • 497
  • 5
  • 15
2
votes
2 answers

Non rails style format of XML response how to parse with ActiveResource correctly?

Using Rails and ActiveResource i am getting non-rails style of XML response form third-party API. Object which i like to map is basically wrapped in prestahop element. What should i override to get rid of that element to map the object…
Jakub Kuchar
  • 1,665
  • 2
  • 23
  • 39
2
votes
1 answer

Setting Rails ActiveResource headers in a thread safe way

I am making calls to an ActiveResource object inside an engine, and I need to set the headers in a thread safe way. I have /lib/mymodule.rb in the engine and it looks something like this: module MyModule def self.my_method() begin data…
Oleksi
  • 12,947
  • 4
  • 56
  • 80
2
votes
1 answer

Consume HTTPS REST API in Rails via ActiveResource

I am pretty new with Rails and REST. I want to consume REST API in Rails. I found an easy and standard way with ActiveResource. API which I want to consume is: https://api.pinterest.com/v2/popular While accessing this API directly, gives response…
Gun
  • 61
  • 1
  • 9
2
votes
1 answer

ActiveResource with conditional prefix (self.prefix)?

Using ActiveResource and when I have a nested resource, using the 'prefix' works great. class Account < ActiveResource::Base self.prefix = "/users/:user_id/" end All is fine as long as :user_id has been defined, or else an error will be raised.…
Carson Cole
  • 4,183
  • 6
  • 25
  • 35