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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:54:11+00:00 2026-06-01T04:54:11+00:00

Something weird’s happening with my Rails app. When I try to send an update

  • 0

Something weird’s happening with my Rails app. When I try to send an update command to one of my controllers, for some reason the submit button appears to be changing some of the params.

I’m using nested resources and setting up races which have participants. Pretty simple. For some reason, though, when I try to update a participant, it changes the value of :race_id to the participant’s id (:id).

Though it only does that on update. I seem to be able to create new participants perfectly using the very same form, and so the very same submit button.

Here is some of the relevant code:

_form.rb (used by new and update)

<%= form_for ([:race, @participant])  do |f| %>
    <%= f.error_messages %>
    <p>
        <%= f.label :name %><br />
        <%= f.text_field :name %>
    </p>
    <p><%= f.submit %></p>
<% end %>

participants_controller.rb

class ParticipantsController < ApplicationController
    before_filter :authenticate_user!, :only => [:edit, :update, :destroy, :create, :new]
    before_filter :set_up_race

...

    def create
        @participant = @race.participants.new(params[:participant])
        if @participant.save
            redirect_to setup_race_path(@race), :notice => "Successfully created participant."
        else
            render :action => 'new'
        end
    end

...

    def update
        @participant = Participant.find(params[:id])
        if @participant.update_attributes(params[:participant])
            redirect_to setup_race_path(@race), :notice  => "Successfully updated participant."
        else
            render :action => 'edit'
        end
    end

...

    def set_up_race
        @race = Race.find(params[:race_id])
    end
end

Here’s why it seems that parameters are being changed:
If I modify the _form.rb file to include <%= params[:race_id] %>
The screen tells me 3

When I click submit I get:

Couldn’t find Race with id=25

Request

Parameters:

{“utf8″=>”✓”, “_method”=>”put”,
“authenticity_token”=>”4VCZP9sI/iv8n454I8AE76n5vLiwGayuXc1NrPYfzGc=”,
“participant”=>{“name”=>”hgdjhgf”}, “commit”=>”Update Participant”,
“race_id”=>”25”, “id”=>”25”}

(As you can see under parameters, “race_id”=>”25″ after I click submit, but the page originally had :race_id =>”3” (proven above, and again if I do anything to make the form crash)).

So the question is, after all of that, why is :race_id changing somewhere between the view and the controller?

EDIT: here’s a rake routes output, as per Jeff’s request:
http://dylancodes.net/personal/ARTk/images/routes.png

  • 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-01T04:54:12+00:00Added an answer on June 1, 2026 at 4:54 am

    What does the url look like that your form is posting to? Based on your routes, I would expect it to look something like /races/3/participants/25. From what I’ve read, the line

    form_for ([:race, @participant]) do |f|
    

    creates a namespaced route (search for “namespaced” on that page) that would look like /races/participants/25.

    Does changing that line to this work for you?

    form_for [@race, @particpant] do |f|
    

    That should build the form url as /races/:race_id/participants/:id.

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

Sidebar

Related Questions

I'm developing an app using threading, and something weird is happening. I have these
Had something weird start happening to me today. I have an asp.net mvc app
Ok this is something weird. I got authlogic-oid installed in my rails app today.
For some reason this function is doing something weird just in Firefox function fadeOUT_sect(id)
So I just saw a weird behavior In one script there is something like:
Something weird is happening to my views all of a sudden (resizing a UITableView
Lately something weird has been happening to my projects in xcode: I've been trying
I realized something weird when I'm coding in javascript, especially with some jquery functions.
Something weird I've never come across before. I wrote this function for one of
Either I'm very tired or something weird is happening that I'm not aware of,

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.