activeresource

Monkey patching ActiveResource::Errors

时光怂恿深爱的人放手 提交于 2019-12-08 06:37:30
I've come across an issue with ActiveResource that has been resolved and was trying to monkey patch it into my application without much luck. I've added a file in config/initializers/ containing the following: class ActiveResource::Errors < ActiveModel::Errors # https://github.com/rails/rails/commit/b09b2a8401c18d1efff21b3919ac280470a6eb8b def from_hash(messages, save_cache = false) clear unless save_cache messages.each do |(key,errors)| errors.each do |error| if @base.attributes.keys.include?(key) add key, error elsif key == 'base' self[:base] << error else # reporting an error on an

rails 3.1.0 belongs_to ActiveResource no longer working

≯℡__Kan透↙ 提交于 2019-12-07 03:58:42
问题 I am upgrading from rails 3.0.7 to 3.1 and am having trouble getting my tests to pass. The problem occurs when I try to use a stubbed active resource object in a factory. #employee.rb class Employee < ActiveResource::Base; end #task.rb class Task < ActiveRecord::Base belongs_to :employee end #factories.rb Factory.define :employee do |e| e.name "name" end Factory.define :task do |t| t.employee { Factory.stub(:employee) } end On the console and in the spec stubbing an employee works.

Undefined method `tagged' for Formatter error after Rails 4 upgrade

浪尽此生 提交于 2019-12-06 23:31:56
问题 I have upgraded from Rails 3.2 to Rails 4 by following the Ruby Screencast guide. My tests are running and the server starts, yet I receive an error when I send a request: ERROR NoMethodError: undefined method `tagged' for #<Formatter:0x000000057f5dc8> /home/mahoni/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.0/lib/active_support/tagged_logging.rb:67:in `tagged' /home/mahoni/.rvm/gems/ruby-2.0.0-p195/gems/railties-4.0.0/lib/rails/rack/logger.rb:21:in `call' /home/mahoni/.rvm/gems/ruby-2.0

CarrierWave with ActiveResource

倖福魔咒の 提交于 2019-12-05 18:20:18
Does anyone have any insights into using CarrierWave with an ActiveResource model (in Rails 3)? I've got an ActiveResource model with field for the filename, and I want to save the file to the remote filesystem. I've tried a few things without much success (or conviction that I was doing anything remotely correctly), so I'd appreciate suggestions from anyone who's successfully implemented CarrierWave without using the ORM modules already included in the gem. I'm probably late for this as the original author has moved on, but this question comes up at the top when someone searches for

rails 3.1.0 belongs_to ActiveResource no longer working

早过忘川 提交于 2019-12-05 07:22:34
I am upgrading from rails 3.0.7 to 3.1 and am having trouble getting my tests to pass. The problem occurs when I try to use a stubbed active resource object in a factory. #employee.rb class Employee < ActiveResource::Base; end #task.rb class Task < ActiveRecord::Base belongs_to :employee end #factories.rb Factory.define :employee do |e| e.name "name" end Factory.define :task do |t| t.employee { Factory.stub(:employee) } end On the console and in the spec stubbing an employee works. Referencing the stubbed employee object in a new task gives the following error. Factory.create( :task, :employee

Undefined method `tagged' for Formatter error after Rails 4 upgrade

时光怂恿深爱的人放手 提交于 2019-12-05 03:24:54
I have upgraded from Rails 3.2 to Rails 4 by following the Ruby Screencast guide. My tests are running and the server starts, yet I receive an error when I send a request: ERROR NoMethodError: undefined method `tagged' for #<Formatter:0x000000057f5dc8> /home/mahoni/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.0/lib/active_support/tagged_logging.rb:67:in `tagged' /home/mahoni/.rvm/gems/ruby-2.0.0-p195/gems/railties-4.0.0/lib/rails/rack/logger.rb:21:in `call' /home/mahoni/.rvm/gems/ruby-2.0.0-p195/gems/quiet_assets-1.0.2/lib/quiet_assets.rb:18:in `call_with_quiet_assets' /home/mahoni/.rvm

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

点点圈 提交于 2019-12-04 07:33:54
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't exactly a Foreign-Key, since I don't have a People table. That leaves several questions: how do I

Active Resource responses, how to get them

不羁的心 提交于 2019-12-04 05:05:05
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 or something? Here's one way to do it without monkeypatching. class MyConn < ActiveResource::Connection

Best way to share ActiveRecord models and data between different Rails Apps?

旧时模样 提交于 2019-12-03 12:04:49
问题 I have several rails applications that will use the same core set of Models and data, for example: Apps Developers Categories Each app builds on top of this core data and uses it in different ways. For example, I might have something like this in another app: Activity Users Apps (shared) Developers (shared) Categories (shared) What is the best way to share the Models and data between them? The Apps, Developers and Category data will all be the same for every app so I would rather not have to

Best way to share ActiveRecord models and data between different Rails Apps?

假如想象 提交于 2019-12-03 02:30:20
I have several rails applications that will use the same core set of Models and data, for example: Apps Developers Categories Each app builds on top of this core data and uses it in different ways. For example, I might have something like this in another app: Activity Users Apps (shared) Developers (shared) Categories (shared) What is the best way to share the Models and data between them? The Apps, Developers and Category data will all be the same for every app so I would rather not have to duplicate the data in every app's database. EDIT: I'm thinking through a couple of possible solutions: