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 8699183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:53:11+00:00 2026-06-13T01:53:11+00:00

This is the update action in notes_controller.rb . def update note = current_user.notes.find(params[:id]) note.update_attributes!

  • 0

This is the update action in notes_controller.rb.

def update
    note = current_user.notes.find(params[:id])
    note.update_attributes! params[:note]
    render json: {note: note.display}
end

It works fine.

My note object has a datetime field called scheduled_time. When the JSON data is returned from the update action on the client side, I need to know if the date that the note’s updated scheduled_time falls on is the same as it was before the update.

def update
    note = current_user.notes.find(params[:id])
    previous_date = note.scheduled_time.to_date
    note.update_attributes! params[:note]
    date_changed = previous_date != note.scheduled_time.to_date
    render json: {note: note.display, date_changed: date_changed}
end

But adding this code causes the note returned in the JSON data (note.display) to contain the values from before the update_attributes!. The update_attributes! still works, but the JSON data returned from the update action does not reflect the update. Why would this be happening?

I’m using

Rails 3.2.0
ruby 1.9.3

I’m also using the Memoist gem generally in the note model, but not on the display method specifically.

  • 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-06-13T01:53:12+00:00Added an answer on June 13, 2026 at 1:53 am

    The issue seems to be the assigning of the note variable and it not being updated with the result set of #update_attributes!. Do you have any hooks or observers going on?

    Try using the Note object directly:

    Note.where(user_id: current_user.id, id: params[:id])
    

    or if all else fails try:

    {display: note.reload.display ... }
    

    It seems to have something to do with the Memoist gem you’re using but I can’t be sure without diving into and simulating this.

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

Sidebar

Related Questions

I have this controller code: def update super respond_to do |format| format.html{redirect_to session[:redirect_to]} end
Can this <%= link_to 'Item', {:controller => items, :action => update, :id => @item,
I have ApiController with Get action like this: public IEnumerable<Note> Get(Guid userId, Guid tagId)
I am using Json to send update information to the following controller action: [HttpPost]
The update statement is like this UPDATE table_name SET column1=value, column2=value2,... WHERE some_column=some_value However
Please help me with this update query. I COMPLETELY understand how redundant this is
I need to position this update button on www.euroworker.no/order (you'll have to add an
I have this update statement: mysql_query (UPDATE loan SET loan_reff_id='$_POST[loan_reff_id]', commit_date='$_POST[commit_date]',app_loan_type='Tertiary Loan', app_ln_amnt='$_POST[app_ln_amnt]', institution_name='$_POST[institution_name]',
Hello I need to do something like this: UPDATE tbl SET pozn=CONCAT(pozn, '+attach_str+') WHERE
I know that in standard SQL you can do this: update top (100) table1

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.