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

  • SEARCH
  • Home
  • 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 7444515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:31:55+00:00 2026-05-29T11:31:55+00:00

I have an ActiveResource based application (referred to as client) that interfaces with an

  • 0

I have an ActiveResource based application (referred to as client) that interfaces with an API application(referred to as api).

I have a model instance, I update the instance through a form, form puts to the client with a simple controller like this:

def update
  @current_user.update_attributes(:psset => params[:permissions])
end

Instead of going to the update controller on the api though, the update controller POSTS to the create controller on the api, not the update, i.e. triggers POST to /users instead PUT to /users/:id. the form always goes to this controller, so the form posts to the client properly.

The most maddening part is that running the command

@current_user.update_attributes(:psset => params[:permissions])

from within pry with the same environment for the same resource will PUT to /users/:id on the api.

So something in that update controller when calling update_attributes is catching that as trying to register a new resource and goes to create on the api.

I’m mystified as to why I can’t update from a controller, but can from a command line instance. This is a first in this situation, with this controller, so there must be something I am doing at some point that triggers a new resource, but can’t figure out what. As usual, I’ll attempt to fill in more specific code based on questions. I know I’m probably just missing something dumb, but what?

EDIT: requested relevant routes

api:

   resources :users do       #, :only => [:index, :show, :create, :destroy]
    collection do
    end
   end

client:

   resources :user, :only => [ :show, :update, :destroy ]

I’m realizing that earlier I made some distinction between user/users in routing and controllers on the client side that looking at I’m not sure is the most efficient method, now hmmm, but it has not been an issue until now. If there is a better way to make that distinction in routes (user/users) without separate controllers I’d like to now, it is just a persnickety user apprehension feature I noticed.

After tweaking routes around and whatnot, the issue persist. I post properly to the client route, that client route goes to create a new resource, not update the existing one (even though it uses params it would use for updating).

UGH, found an answer sort of. I started using the cached_resource gem with this client, and I recently turned it on for all the models. Turned it off for the user model, problem gone. Putting caching solutions to the future once more.

  • 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-29T11:31:56+00:00Added an answer on May 29, 2026 at 11:31 am

    Logic of activeresource update_attributes is next

    File activeresource/lib/active_resource/base.rb, line 1306

    def update_attributes(attributes)
      load(attributes, false) && save
    end
    
    # File activeresource/lib/active_resource/base.rb, line 1147
        def save
          new? ? create : update
        end
    

    so it can post or put depends on result of new? method
    here is that method (it depends on persisted)

    File activeresource/lib/active_resource/base.rb, line 1047

    def new?
      !persisted?
    end
    

    Explanation is here
    http://api.rubyonrails.org/classes/ActiveResource/Base.html#method-i-persisted-3F

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

Sidebar

Related Questions

I'm building an application that consumes models through an api with ActiveResource. I noticed
I have a simple jruby+swt based client that collects data on an occasionally connected
I have an application that interacts with ActiveResource from a system I have no
I have a web app that is using ActiveResource to talk to another server
In my Rails 3.1.1 project I have an ActiveModel that talks to API (ripped
actionmailer actionpack activeresource activesupport I have a basic scaffolded CRUD app that uses ActiveRecord
I am getting a really strange error from ActiveResource. I have a method that
I have a model class that is not bound to Active record. class ProcessingStatus
I have a Rails application that has a Company resource with a nested resource
I have several ActiveResource model in my project. There was so strange to me

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.