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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:33:28+00:00 2026-05-26T06:33:28+00:00

I have the following form in a rails app which is not working: <%

  • 0

I have the following form in a rails app which is not working:

<% form_remote_for :team  do |f| %>
  <tr>
    <% 1.upto(12) do |i| %>
      <td>
        <%= f.check_box @mo[i] %>
        <%= observe_field 'team_' + @mo[i], 
          :method => :put,
          :with => "$(@mo[i] + '=') + $('team_'+@mo[i]).value" %>
      </td>
    <% end %>
  </tr>
<% end %>

@mo[i] is the name of the field in the database (e.g. jan, feb, mar,… dcm). The code would look like this if i were to write them all out:

<% form_remote_for :team  do |f| %>
  <tr>
    <td>
        <%= f.check_box :jan %>
        <%= observe_field 'team_jan', 
          :method => :put,
          :with => "'jan=' + $('team_jan').value"
    </td>
    ...
  </tr>
<% end %>

Thanks for your help.

  • 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-26T06:33:28+00:00Added an answer on May 26, 2026 at 6:33 am

    Your :with statements has some syntax problems, and you are also not interpolating your ruby variables correctly. Try this:

      :with => "'#{@mo[i]}=' + $('team_#{@mo[i]}').value"
    

    I derived this by taking your intended output 'jan=' + $('team_jan').value and replacing all instances of jan with #{@mo[i]}, which is the way to interpolate your variable that contains the month name.

    Also, you probably need to add a :url option to tell where your ajax call should be sent. Something like this:

    <%= observe_field 'team_jan',
            :url => team_path(@team),
            :method => :put,
            :with => "'#{@mo[i]}=' + $('team_#{@mo[i]}').value" %>
    

    I am guessing here that your desired endpoint is team_path(@team), but replace it if it is not.

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

Sidebar

Related Questions

We have the following code working for a complex rails form with checkboxes. I'm
I have the following rails form (which works) but I want to remove the
I have the following form, which I have reduced as much as I can,
I have the following form for photo_album which uses the nested forms feature of
I have the following form <form name=myForm id=myForm method=post enctype=multipart/form-data action=script.php> and this jQuery
I have an Ajax form in my Rails app that contains the Recaptcha markup
I have a Rails app with a Route resource, and a Route controller (not
Using Rails 3.2.0.rc2 and ruby 1.9.3p0 In app/views/requests/_form.html.erb I have the following code for
I have the following situation in a Ruby on Rails app: user fills in
Environment: Rails 3.0.4 and Ruby 1.9.2 I have the following form: <%= form_tag( {:action

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.