Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6917515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:44:24+00:00 2026-05-27T09:44:24+00:00

The ActiveResource::Base#update_attributes method calls a ActiveResource::Base#load method which is defined in activeresource-3.1.3/lib/active_resource/base.rb (line 1255).

  • 0

The ActiveResource::Base#update_attributes method calls a ActiveResource::Base#load method which is defined in activeresource-3.1.3/lib/active_resource/base.rb (line 1255). I am trying to call that load method, rather than simply using update_attributes so that the object is not saved immediately.

  1. I tested this with a completely new rails application. I scaffolded a simple object:

    rails scaffold obj property1:string
    
  2. Then in the rails console:

    irb(main):001:0> obj=Obj.new
    irb(main):002:0> obj.load(:property1=>"data")
    TypeError: can't convert Hash into String
    from .../activesupport-3.1.3/lib/active_support/dependencies.rb:234:in `load'
    from .../activesupport-3.1.3/lib/active_support/dependencies.rb:234:in `load'
    from .../activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `load_dependency'
    from .../activesupport-3.1.3/lib/active_support/dependencies.rb:640:in `new_constants_in'
    from .../activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `load_dependency'
    from .../activesupport-3.1.3/lib/active_support/dependencies.rb:234:in `load'
    from (irb):2
    

I see that activesupport-3.1.3/lib/active_support/dependencies.rb applies its Loadable module to Object, giving every object a load method for loading files, but I can’t figure out why it overrides the ActiveResource::Base#load method and not the other way around.

I am using Rails 3.1.3 and friends.

Update:

I think I’ve answered my own question. I’ve been trying to use ActiveResource methods on ActiveRecord objects. I know that my Rails model classes are descendants of ActiveRecord::Base, but somehow when I was trying to find the code for ActiveRecord::Base#update_attributes I found the code for ActiveResource::Base#update_attributes instead, which looks like this:

def update_attributes(attributes)
  load(attributes, false) && save
end

So I’ve been trying to call the load method, which exists for my objects only as provided by activesupport. If I had only looked at ActiveRecord::Base#update_attributes which is

def update_attributes(attributes, options = {})
  # The following transaction covers any possible database side-effects of the
  # attributes assignment. For example, setting the IDs of a child collection.
  with_transaction_returning_status do
    self.assign_attributes(attributes, options)
    save
  end
end

I would have seen that the assign_attributes method is what I needed.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T09:44:24+00:00Added an answer on May 27, 2026 at 9:44 am

    Instead of doing that, you could use .attributes

    obj = Obj.new
    obj.attributes = { :property1 => "data" }
    

    The instance has new attributes, but has not been saved.

    Read the Docs for more info.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to debug an ActiveResource call that is not working. What's the
I am getting a really strange error from ActiveResource. I have a method that
I 've researched and noticed that ActiveResource lack this functionality. So, what is the
I'm trying to get my head around nested associations in Rails using ActiveResource. My
i have a rails app which makes heavy use of activeresource and httparty to
I have this code: require 'rubygems' require 'activeresource' ActiveResource::Base.logger = Logger.new(#{File.dirname(__FILE__)}/exercises.log) class Exercise <
actionmailer actionpack activeresource activesupport I have a basic scaffolded CRUD app that uses ActiveRecord
Here are the entire contents of activeresource.rb : require 'active_resource' Could someone explain the
With ActiveResource, a call to MyObject.find(id) gets [self.site]/[self.prefix]/:id.[self.format]. However, the API we're accessing is
I have rails applications, which communicate with each other using ActiveResource. I have setup

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.