activeresource

Unfuddle API get accounts info

独自空忆成欢 提交于 2019-12-13 17:42:59
问题 I'm trying to get the account info from Unfuddle API using ActiveResource The url is http://mydomain.unfuddle.com/api/v1/account this is my ActiveResource class class Account < ActiveResource::Base self.collection_name = "account" self.site = "https://mydomain.unfuddle.com/api/v1" self.user = "me" self.password = "pass" end if I try getting my account info with Account.all I'll get an empty array but if I try this require 'net/https' UNFUDDLE_SETTINGS = { :subdomain => 'mydomain', :username =

Overriding/Modifying Rails Class (ActiveResource)

眉间皱痕 提交于 2019-12-13 02:01:56
问题 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

Using ActiveResource without Rails

我只是一个虾纸丫 提交于 2019-12-12 22:13:09
问题 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 . 回答1: Indeed you can. ActiveResource is a separate library. However, ActiveResource depends on ActiveSupport, so make sure you include both as requirements in your code. 回答2: Yes it's possible to use ActiveResource separately. You can find good documentation on the project

ActiveResource + Caching

馋奶兔 提交于 2019-12-11 13:36:50
问题 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. So there is no built in caching that I'm used to with ActiveRecord. Time to expand my knowledge and skill base, ok. I found this: http://injectisforwizards.com/blog/read-through-caching-of-activeresource/, and while I don't understand this 100% yet,

XML serializing arrays with type=“array” in .NET

我的未来我决定 提交于 2019-12-11 12:49:17
问题 I'm attempting to serialize a class to XML, but I have some strict requirements on the output (because I want Rails' ActiveResource to consume it). One of those requirements is specifically for arrays. Here's two examples: class Person { public string FirstName { get; set; } } List<Person> people = new List<Person>(); people.Add( new Person {...} ); people.Add( new Person {...} ); If I serialize the people list, I need this output: <People type="array"> <Person> <FirstName>blah</FirstName> <

Device & ActiveResource

牧云@^-^@ 提交于 2019-12-11 09:48:37
问题 I want to have 1 database for few projects and only one of them have direct connection to db, first of all I want to implement user authentication. I should work over REST , without connecting to database. D you have any experience with devise gem working together with active resource. Thank you. 回答1: Sounds like you're looking for a single-sign-on solution. What you can do is setup one application to have a REST API, and enable single sign on for it which the others can utilize to connect to

Consuming REST API Rails

痴心易碎 提交于 2019-12-11 05:39:43
问题 I've looked at this question but it's quite old and I feel there's now other alternatives to ARes. Given that many people seem to think that ActiveResource is kind of outdated and heavyweight, I've looked at Api Smith, Her, Roar and of course ARes. Which one of these gems would be the most reliable, and future proof alternative? 回答1: Why not using lower level libraries like HTTParty or Faraday ? They will cover a lot of the ugly stuff for you (ssl, parsing/serializing jsons and XMLs, logging,

Rails: Run initializer before creating classes

只谈情不闲聊 提交于 2019-12-11 01:17:43
问题 Basically I have an initializer class at RAILS_ROOT/config/initialiers/app_constant.rb to make everything easy to control. class AppConstant APIURL = 'http://path.to.api' end And in the RAILS_ROOT/model/user.rb , I have the settings: class User < ActiveResource::Base self.site = AppConstant::APIURL end And when run rails s , I got the following error <class:User>: uninitialized constant User::AppConstant::APIURL I know that the problem is because Rails run Initializers after creating the

How do I create an ActiveRecord relationship to an ActiveResource object?

China☆狼群 提交于 2019-12-09 18:24:09
问题 Let's say I'm writing a Library application for a publishing company who already has a People application. So in my Library application I have class Person < ActiveResource::Base self.site = "http://api.people.mypublisher.com/" end and now I want to store Article s for each Person : class Article < ActiveRecord::Base belongs_to :person, :as => :author end I imagine I'd have the following table in my database: Articles id (PK) | title (string) | body (text) | author_id (integer) author_id isn

Active Resource responses, how to get them

♀尐吖头ヾ 提交于 2019-12-09 17:02:59
问题 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 response. What would be the most efficient way of doing this from IRB? I don't have the luxury of Rails or other frameworks that might provide the underlying response. Do I need to hack Net::HTTP or ActiveResource itself with a monkeypatched call