activeresource

Overriding/Modifying Rails Class (ActiveResource)

耗尽温柔 提交于 2019-12-02 07:25:05
I've been struggling with an issue with ActiveResource for a bit now: when a hostname resolves for an ActiveResource request, but there's no server on the other end to return information, ActiveResource's timeout value doesn't work. The request just hangs. After reviewing the ActiveResource code, I've realized that this is because the underlying Net:Http object only has one timeout value set: read_timeout. The Net:Http library defines this as "Seconds to wait until reading one block (by one read(2) call)". The Net:Http lib also defines another timeout value, open_timeout, which is defined as

Set site/user fields in ActiveResource

时光毁灭记忆、已成空白 提交于 2019-12-02 05:20:27
问题 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 Resource HTTP authentication on a per-user basis?. I add code (shown below) and I get an error. Can anyone help understand this error and how to fix it. class ActiveResource::Base class << self %w(site user).each do |attr| define_method(attr) do

Set site/user fields in ActiveResource

淺唱寂寞╮ 提交于 2019-12-02 01:01:58
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 Resource HTTP authentication on a per-user basis? . I add code (shown below) and I get an error. Can anyone help understand this error and how to fix it. class ActiveResource::Base class << self %w(site user).each do |attr| define_method(attr) do Thread.current["active_resource.#{attr}"] end define_method("#{attr}=", val) do Thread.current["active

Active resource complaining about expects an hash

大城市里の小女人 提交于 2019-12-01 16:46:39
问题 I am using active resource to get data from an api and display it, My controller model.rb has class Thr::Vol::Dom < ActiveResource::Base class << self def element_path(id, prefix_options = {}, query_options = nil) prefix_options, query_options = split_options(prefix_options) if query_options.nil? "#{prefix(prefix_options)}#{collection_name}/#{id}#{query_string(query_options)}" end def collection_path(prefix_options = {}, query_options = nil) prefix_options, query_options = split_options

Remove .xml extension from ActiveResource request

痞子三分冷 提交于 2019-11-30 17:31:13
I am trying to use ActiveResource to consume xml data from a third party API. I can use the RESTClient app to successfully authenticate and make requests. I coded my app and when I make a request I get a 404 error. I added: ActiveResource::Base.logger = Logger.new(STDERR) to my development.rb file and figured out the problem. The API responds with xml data to requests that do NOT end in xml. EG, this works in RESTClient: https://api.example.com/contacts but ActiveResource is sending this request instead https://api.example.com/contacts.xml Is there anyway "nice" way to strip the extension from

Add api key to every request in ActiveResource

余生颓废 提交于 2019-11-30 08:23:19
I have 2 RESTful Rails apps I'm trying to make talk to each other. Both are written in Rails 3 (beta3 at the moment). The requests to the service will require the use an api key which is just a param that needs to be on every request. I can't seem to find any information on how to do this. You define the url the resource connects to via the site= method. There should be an equivalent query_params= method or similar. There is one good blog post I found related to this and it's from October 2008, so not exactly useful for Rails 3. Update : I had a thought. Would a small Rack middleware or Metal

Add api key to every request in ActiveResource

試著忘記壹切 提交于 2019-11-29 11:09:43
问题 I have 2 RESTful Rails apps I'm trying to make talk to each other. Both are written in Rails 3 (beta3 at the moment). The requests to the service will require the use an api key which is just a param that needs to be on every request. I can't seem to find any information on how to do this. You define the url the resource connects to via the site= method. There should be an equivalent query_params= method or similar. There is one good blog post I found related to this and it's from October

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

岁酱吖の 提交于 2019-11-27 18:21:40
问题 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 type a student sits in and a teacher educates in. When the user submits an HTTP POST to create a new class for their application, a lot of the key value pairs look like: student_name: Bob Smith student_name: Jane Smith student_name: Chris Smith What's

Is it thread safe to set Active Resource HTTP authentication on a per-user basis?

只愿长相守 提交于 2019-11-27 15:08:50
Active Resource can make use of HTTP authentication set at the class level. For instance: class Resource < ActiveResource::Base end Resource.user = 'user' Resource.password = 'password' or Resource.site = "http://user:password@site.com/" But what if I use different HTTP authentication based on which user is logged in? If I change Resource.user and Resource.password, is that going to cause a race condition where requests from one thread suddenly start using the authentication of a user whose requests are running simultaneously in a different thread? Or is this a non-issue (as long as I reset

RESTful frameworks for Android, iOS…?

荒凉一梦 提交于 2019-11-27 10:53:46
My company is reworking its API and wants to make everything RIGHT for this time ;) Thats the setup... We are delivering data to clients over the internet. Clients are mobile handsets like iPhone, Androids, J2ME, Blackberry... The server is coded in Ruby on Rails We want to achieve through a framework... Take use of ActiveResource on the clients. The framework should do the connection (REST), parsing and (dynamically) providing of models Licence must be open source. Authorization shall be included. We use OAuth and need to deliver the Access Token on any request. Maybe as parameter or in the