problem about activeresource-Collection of common programming errors


  • Carson Cole
    ruby-on-rails ruby-on-rails-3 activeresource
    Using ActiveResource and when I have a nested resource, using the ‘prefix’ works great.class Account < ActiveResource::Baseself.prefix = “/users/:user_id/” endAll is fine as long as :user_id has been defined, or else an error will be raised. But how to make the ‘self.prefix’ conditional, in cases where I don’t want to access this resource as a nested resource, but rather as the resource itself? For example, I’d like to retrieve all accounts, not just the accounts scoped by a particular user?

  • Sainath Mallidi
    ruby-on-rails activerecord activeresource
    I am stuck on how to set the site variable to ActiveResource at runtime, I read this post which explains how to do the samehttp://blog.rubybestpractices.com/posts/gregory/rails_modularity_1.htmlBut the only problem there is the mapping from service name to url is predefined. In my case its the same service except in different domain and return identical results.domain1.mydomain.com domain2.mydomain.comThis active resource belongs to another active record model and which domain to access depends

  • Aaron Mcguire
    ruby rubygems gem activeresource ruby-2.0
    I have a gem I’ve created ( https://github.com/samcreate/Simon ) that doesn’t work with ruby-2.0.0-p247 (works fine in 1.9.3). I get two errors that I’ve found very little help with –by my own searching abilities. Below is the error stack but I’ve added a little detail each error to show some of my own findings.simon create /Users/aaron.mcguire/.rvm/gems/ruby-2.0.0-p247/gems/commander-4.1.3/lib/commander/runner.rb:365:in `block in require_program’: program version required (Commander::Runner::C

  • Steve Wright
    ruby-on-rails rest ruby-on-rails-3 activeresource
    I have a REST API that I am trying to access using Rails 3.0.1 that returns:<Sessions><Session><Title>This is a sample title</Title>…Misc</Session><Session><Title>Another Title</Title>…Misc</Session> </Sessions>I have set up my session.rb class defined:class Session < ActiveResource::Baseself.site = “http://example.com/rest” endThe url that will return the XML is http://example.com/rest/sessions.I then have a controller that is d

  • ere
    ruby-on-rails ruby-on-rails-3 json activeresource freebase
    I’ve got ActiveResource setup to consume the freebase api in json, and it should work fine except that the json freebase returns causes ActiveResource to blowup.NoMethodError: undefined method `collect!’ for #<Hash:0x007fd674831dd0>How can I define a custom json parser to fix whatever is wrong?class Freebase < ActiveResource::Baseself.site = “https://www.googleapis.com/”self.format = :jsondef self.search(word)self.find(:all, :from => “/freebase/v1/search/”, :params => { :query =&g

  • codinghands
    ruby-on-rails shopify activeresource
    I’m unable to add ‘new’ RESTful entities without defining a schema in my RoR ActiveResource model, even though I’ve read this is optional. When omitting the schema (I’ve included it in the code below for clarity), I receive the following error:NoMethodError in Pages#newundefined method `author’ for #<Page:0x4823dd8>When I include the scheme, everything works as expected. I’d really rather not have to keep track of the schema every time it changes, and I’ve seen examples that don’t require

  • Muflix
    ruby-on-rails activeresource
    I have database table storemodel name models/store/store.rbclass Store::Store < ActiveRecord::Base … endcontroller controllers/store/maintenance_controller.rbclass Store::MaintenanceController < ApplicationControllerdef index@stores = Store.allrespond_to do |format|format.html # index.html.erbformat.json { render json: @stores }endenddef new@store = Store.newrespond_to do |format|format.html # new.html.erbformat.json { render json: @store }endendroutes.rbnamespace :store doroot :to =>

  • ere
    ruby-on-rails ruby-on-rails-3 rest activeresource freebase
    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 but I don’t know how to check what’s going on?Error:ActiveResource::ResourceNotFound: Failed. Response code = 404. Response message = Not Found.Code:class Freebase < ActiveResource::Baseclass << self # also tried without this, same resultdef

  • KL-7
    ruby activeresource highrise
    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::Baseclass << self%w(site user).each do |attr| define_method

  • OVERTONE
    ruby-on-rails ruby oop activerecord activeresource
    So I come from a background in Java where you can create a class as such.TestClass x = new TextClass();and call its method like x.shout();I’m attempting to do something similar in ruby with no such look. This could be syntactical or it could be I don’t understand the concept of ruby and rails well.So heres a class on a server in Rubyclass myResource< ActiveResource::Baseself.site = “http://localhost:3008″def self.shoutputs “I AM AN ACTIVE RESOURCE SHOUT!”puts ” CAPS RAGE YEAH!”puts Time.nowen

  • user2122528
    ruby ruby-on-rails-3 api openssl activeresource
    I have two rails apps running on different ports. From one app I am trying to consume the API of the other app. Here’s the code for Product.rb model in APP_1. class Product < ActiveResource::Baseself.site = “https://localhost:3000″self.ssl_options = {:cert => OpenSSL::X509::Certificate.new(File.open(pem_file)),:key => OpenSSL::PKey::RSA.new(File.open(pem_file)),:ca_path => “/path/to/OpenSSL/formatted/CA_Certs”,:verify_mode => OpenSSL::SSL::VERIFY_PEER} endI

  • Charlie Somerville
    ruby-on-rails routing activeresource
    I have this in my view:form_for [:support, @thread, @reply], url: support_thread_replies_path do |f|And this in my routes.rb:namespace :support doresources :threads doresources :repliesend endThat doesn’t work:Routing ErrorNo route matches {:action=>”new”, :controller=>”support/replies”}If I remove the url: key from my form_for, I just get a NoMethodError when the form helper tries to call an undefined path helper method:I get the same Routing Error even when I remove the :support symbol f

  • cwadding
    ruby activeresource
    This seems like a simple problem but I can’t seem to find the answer. I have a UTC time (ie. 1323481111) and I want to change it to a DateTime or TimeWithZone object in a ruby script. I haven’t found a way to do it with just ruby but I believe there should be a way to do it using ActiveSupport. It seems to me that I should be able to do it as follows:require “active_support/all”Time.zone.at(1323481111)http://api.rubyonrails.org/classes/ActiveSupport/TimeZone.htmlBut that doesn’t seem to work. An

  • Kir
    ruby api activeresource basecamp
    My code:require ‘rubygems’ require ‘basecamp’ basecamp = Basecamp.establish_connection!(‘example.basecamphq.com’, ‘example’, ‘123456’, true) projects = Basecamp::Project.find(:all) projects.inspectIt gives:/Users/kir/.rvm/gems/ruby-1.8.7-p352@project/gems/activeresource-3.1.0/lib/active_resource/base.rb:922:in `instantiate_collection’: undefined method `collect!’ for #<Hash:0x105faa450> (NoMethodError)from /Users/kir/.rvm/gems/ruby-1.8.7-p352@project/gems/activeresource-3.1.0/lib/active_re

  • OVERTONE
    ruby-on-rails ruby activerecord methods activeresource
    So continuing on my adventure of active resource and active record I’m trying to do a simple get method within an active resource but everytime I try to reference the variable, It throws a method undefined exception. Perhaps Its better to explain it in code.class UserRequest < ActiveResource::Baseself.site = “http://localhost:3008″def get_status puts self.statusreturn self.statusendThe active record on the other side is made up of of URL, depth and status. So i go through the console as one w

  • Jones Agyemang
    ruby-on-rails ruby callback mongoid activeresource
    Getting an obscure error which originates from the ActiveResource standard Rails library. The line within Rails causing this problem is given below along with the output. Any idea on how to resolve this problem please?class Search < ActiveResource::Nestful::Baseself.collection_name = “search”schema dostring :typeobject :eventenddef self.query(params)find(:all, :params => params) enddef self.per_page3 enddef recordattributes[attributes[“type”]] end endOUTPUTStarted GET “/search?utf8=%E2%9C%

  • aletapool
    ruby activeresource
    What I am missing? I am trying to use a rest service for with Active resource, I have the following:class User < ActiveResource::Baseself.site = “http://localhost:3000/”self.element_name = “users”self.format = :json enduser = User.new(:name => “Test”,:email => “[email protected]”)p user if user.saveputs “success: #{user.uuid}” elseputs “error: #{user.errors.full_messages.to_sentence}” endAnd the following output for the user: #<User:0x1011a2d20 @prefix_options={}, @attributes={“n

  • Krista
    ruby-on-rails activerecord logging ruby-on-rails-3.1 activeresource
    So I have an application that earlier did not need ActiveRecord – thus we removed ActiveRecord from the application and formatted our logging as such:In application.rb:class DreamLogFormatter < Logger::FormatterSEVERITY_TO_COLOR_MAP = {‘DEBUG’=>’32’, ‘INFO’=>’0;37’, ‘WARN’=>’35’, ‘ERROR’=>’31’, ‘FATAL’=>’31’, ‘UNKNOWN’=>’37’}def call(severity, time, progname, msg)color = SEVERITY_TO_COLOR_MAP[severity]”\033[0;37m[%s] \033[#{color}m%5s – %s\033[0m\n” % [time.to_s(:short), s

  • Rob Conery
    ruby-on-rails xml-rpc activeresource
    I’ve seen a ton of examples with ActionWebService and XMLRPC, but they’re 3 years old and from what I understand, ActiveResource is supposed to replace ActionWebService.I’m familiar with how ActiveResource can use XML to “talk” to other web sites and consume model information, but XML-RPC is a whole different type of thing, wherein you pass the name of the method you want to execute and the request is handed off, etc.EDIT – I know how ActiveResource is supposed to work – but I have a client app

  • jurer
    ruby-on-rails ruby client-server activeresource has-and-belongs-to-many
    On my server, I have two models:Broadcastclass Broadcast < ActiveRecord::Basevalidates_presence_of :contentbelongs_to :userhas_and_belongs_to_many :feedsattr_accessible :content, :feeds, :feeds_attributesendFeedclass Feed < ActiveRecord::Basehas_and_belongs_to_many :broadcastsattr_accessible :name endOn my client, I have basic ActiveResource classes for those models.When I try to create new Broadcast with given Feeds (from client):feed = Feed.find(3) <-succesfulbroadcast = Broadcast.new