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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:48:32+00:00 2026-06-17T12:48:32+00:00

I have an ajax request that sends data to my controller, but i want

  • 0

I have an ajax request that sends data to my controller, but i want to add elements to the hash before saving it to the db.

My existing hash looks like this:

{"application_field_attributes"=>{"0"=>{"id"=>"10"}}}

I also have elements params[:xposition], and params[:yposition] that i want to add to the hash above so that it looks like this:

{"application_field_attributes"=>{"0"=>{"id"=>"10", "xposition"=>"1", "yposition"=>"0"}}}

How do i go about doing this?

EDIT

The reason i’m doing this is because i’m trying to keep track of where draggable elements are dropped on a grid.

In my ajax call, i pass in the x and y position which i get from some “data-id” attributes i placed on the grid.

In my controller method, i currently have @application.update_attributes(params[:application]), but it doesn’t contain the xposition and yposition and that’s why i’m trying to inject them to the hash.

Maybe a better solution would be to manually update the x and y positions in the controller after the update_attributes command?

So it would look something like:

@application.update_attributes(params[:application])
@application.update_xposition(params[:xposition])
@application.update_yposition(params[:yposition])
  • 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-17T12:48:33+00:00Added an answer on June 17, 2026 at 12:48 pm

    You might want to do that differently.

    Maybe a better idea would be to have hidden fields in your form with xposition and yposition, for instance.

    Could you tell us more about what you’re trying to do, what are x/yposition (if they are different for every application, and where do they come from).

    To answer your question though:

    app_attrs = {"application_field_attributes"=>{"0"=>{"id"=>"10"}}}
    app_attrs["application_field_attributes"]["0"].merge!({
        "xposition" => params[:xposition],
        "yposition" => params[:yposition]
    })
    

    But I wouldn’t do that if I were you.

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

Sidebar

Related Questions

I have data that I want to send through an ajax GET request in
I have an Ajax request that sends some data to a page and expects
I have jQuery Ajax request that sends data to a PHP page that then
I have a tooltip on an anchor element, that sends an AJAX request on
I have several HTML elements (buttons) that fire the same JQuery AJAX request. When
So I have some javascript code that sends data to my controller: Javascript: <script
I have a web page that thats sends an Ajax request with a javascript
I have ajax request that do 3 missions: Save Model (DB) Send Email Give
I have an app that sends multiple Ajax requests simultaneously. I was originally running
I have an Ajax request that can return more than one valid value, so

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.