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
1
vote
2 answers

Rails nested resources

I'm trying to get my head around nested associations in Rails using ActiveResource. My example is as follows: What I have is an airport with many runways. My show action in airports controller contains: @airport = Airport.find(params[:id]) When…
Matt
  • 1,610
  • 2
  • 17
  • 24
1
vote
1 answer

ActiveResource + Caching

I'm building an application that consumes models through an api with ActiveResource. I noticed that the @resource ||= @resource.do a query doesn't work, i.e. If I put something like that in my controller, my application will still query the api.…
blueblank
  • 4,724
  • 9
  • 48
  • 73
1
vote
1 answer

ActiveResource .create without error, but isn't persisted

require 'active_resource' class MyRsrc < ActiveResource::Base self.site = "http://localhost:9292/api/0/category/sys_demo" self.element_name = "myname" end # from https://github.com/anibalcucco/basecamp-wrapper/issues/11 class Hash def…
bshanks
  • 1,238
  • 2
  • 12
  • 24
1
vote
2 answers

What are the consequences of overriding Array.to_param within an ActiveResource based plugin

An active_resource based class: Contact.search(:email => ['bar@foo.com','foo@bar.com']) would produce this: ?email[]=bar@foo.com&email[]=foo@bar.com The specific API that I'm working with requires this: ?email=bar@foo.com&email=foo@bar.com So…
ktec
  • 2,453
  • 3
  • 26
  • 32
1
vote
1 answer

Where and how does Active Resource execute its HTTP requests?

I can't find the place where Active Resource initiates its connections. I was expecting Connection.request to call into a networking library, but instead it merely calls into ActiveSupport::Notifications.instrument, which appears to be some kind of…
Nick Urban
  • 3,568
  • 2
  • 22
  • 36
1
vote
1 answer

howto make activeresource new record match expected post data

I have a resource there posting "host[name]=example.com" to it - creates a new host record with name example.com The following works curl http://localhost:3300/hosts.xml --request POST --data "host[name]=example.com" Trying to do the same with…
Piavlo
  • 126
  • 5
1
vote
1 answer

Active Resource in Unobtrusive Javascript

I don't know any better way to ask this question than to give my situation. I have a reader application that needs to be made, on the page it will have the Table of Contents on the left side and the actual content of the book on right. The TOC…
Eric C
  • 2,195
  • 1
  • 17
  • 23
1
vote
2 answers

Refresh ActiveResource Cache

I have an active resource model in one of my applications, and I need to be able occasionally do a find(:all), and force it to repull the data from the remote service. How can I do this? I saw the connection(refresh=true) piece, but I don't want it…
jasonpgignac
  • 2,296
  • 2
  • 19
  • 26
1
vote
1 answer

Best way to have a model with two different data sources

I have a rails model where some part of data comes from database and other by calling a restful web service. Is there a way to use both ActiveRecord and ActiveResource in the same model to achieve this? Ideally I would like to load the attributes…
Sainath Mallidi
  • 515
  • 1
  • 7
  • 17
1
vote
1 answer

Ruby on rails: model name uninitialized error (mismatch of module)

I am accessing model Company::Item in controller Security::MyController. It is giving error uninitialised constant Security::Company::Item . So basically it is appending 'Security::' for given model. It is not the case with some other models say…
1
vote
2 answers

Zerigo DNS gem incompatible with ActiveResource 3.1

I'm using the zerigo_dns 1.2.0 gem (https://github.com/twilson63/zerigo_dns) and it needs to make a 'request' call using ActiveResource. It was working fine with Rails 3.0.4 because the default format was XML. But Rails 3.1.0.rc4 uses JSON as…
mountriv99
  • 923
  • 8
  • 13
1
vote
1 answer

create activeresource model factory using Factory Bot in rails

How to create rspec factory of activeresource model?
Ch Zeeshan
  • 11
  • 1
1
vote
1 answer

How Does the ActiveResource Get Call show find(:first) or find(:last) requests?

I am developing a Sinatra server that can accept calls from ActiveResource, but can"t determine how to identify Get calls specificying :first or :last. In Rails 3 User.find(:first) => localhost.com/user.xml User.find(:last) =>…
Scott
  • 330
  • 3
  • 15
1
vote
0 answers

ActiveResource adding about 1 second of overhead?

I have two simple Ruby on Rails applications with one using ActiveResource to access the other. The ActiveResource processing seems to be adding ~1000ms of overhead. These are the trace logs: Requester: Started GET…
Robert Mitchell
  • 133
  • 1
  • 6
1
vote
2 answers

Rails ActiveResource HABTM return values

I have two models: Company and User they have a has_and_belongs_to_many relationship. I'm using active resource with a method to get all users of a company: def users @company = Company.find( params[:id], :include => [:users] ) render :xml =>…
brad
  • 31,987
  • 28
  • 102
  • 155