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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:42:34+00:00 2026-05-16T18:42:34+00:00

I have a _form.html.erb partial that comes from the standard rails 3 template for

  • 0

I have a _form.html.erb partial that comes from the standard rails 3 template for the model project.

    #view:
    <div id="content">
      <%= link_to 'Edit', edit_project_path(@project), :remote => :true %>
    </div>

    #projects controllers
    def edit
        @project = Project.find(params[:id])

        respond_to do |format|
          format.html # edit.html.erb
          format.js { render "form.js.rjs" }
        end
      end

    #form.js.rjs
    page.replace_html "content", :partial => 'form'

    #_form.html.erb
    <%= form_for(@project) do |f| %>
      <% if @project.errors.any? %>
        <div id="error_explanation">
          <h2><%= pluralize(@project.errors.count, "error") %> prohibited this project from being saved:</h2>

          <ul>
          <% @project.errors.full_messages.each do |msg| %>
            <li><%= msg %></li>
          <% end %>
          </ul>
        </div>
      <% end %>
      <p>
        <%= f.label :name %>
        <%= f.text_field :name %>
      </p>

      <div class="actions">
        <%= f.submit %>
      </div>
    <% end %>

While i click that link to edit a project, the form does come through through ajax, but the method for the form is now post instead of put. which means as i submit, it will create new projects with the same attributes as the existing one that I am editing b/c of the create method that’s called upon receiving a post request.

I know that form_for(@project) rely on record id to tell whether it’s new or not, I looked through all the sources for form_for, form_tag, extras_tags_for_form, form_tag_html but cannot find a place where they specify which method for the form tag is to be used. The closest place where it defines the method is in extra_tags_for_form, but in that method, it is merely sieving through the :method option hash that’s already passed to it, but from where is this :method option passed? I cannot find.

any ideas?

  • 1 1 Answer
  • 2 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-16T18:42:34+00:00Added an answer on May 16, 2026 at 6:42 pm

    You are on the right track, form_form(obj) will look at the objects dirty flag to figure out what to do with it. That doesn’t mean you can’t tell it what to do though 🙂

    form_for actually has a few hashes in its optional params, :method lives inside :html. so to force it to be put, just do something like this

    form_for @project, :html => {:method => :put} do |f|
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a large Ruby on Rails form that has the following partial view
I have a nested form in a rails view that is called like this
I have a partial called _avatar.html.erb I want to pass in an id as
I have problems displaying error_messages.html.erb partial when building custom validation. I have for instance,
I have a following problem, I have HTML form that uploads a file with
I have a HTML form that has certain fields which i am opening inside
I have a HTML form that accepts a comma separated list of tags, which
This is the relevant part of my _form.html.erb <%= form_for(@score) do |f| %> <%
I am appending code to a div block from a partial using unobtrusive javascript.
I have a Rails nested form with the child fields that contain dynamic select

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.