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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:33:29+00:00 2026-06-05T06:33:29+00:00

Here’s what I have in my users/edit.html/erb <%= form_for(resource, :as => resource_name, :url =>

  • 0

Here’s what I have in my users/edit.html/erb

<%= form_for(resource, :as => resource_name, :url => user_path(resource_name), :html => { :method => :put }) do |f| %>

My routes for user:

           edit_user GET    /users/:id/edit(.:format)      users#edit
                user GET    /users/:id(.:format)           users#show
                     PUT    /users/:id(.:format)           users#update

method => put, so using the routes info, I am expecting the HTML action to be /users/:id

This being users/edit.html.erb, I am expecting the HTML for from id to be edit_user_id, and class to be edit_user

Here’s what I’m actually getting in HTML (using firebug) when the form is displayed:

<form id="new_user" class="new_user" method="post" action="/users/user" accept-charset="UTF-8">

Shouldn’t the HTML have been (assuming a user id of 1):

<form id="edit_user_1" class="edit_user" method="post" action="/users/1" accept-charset="UTF-8">

In my routes.rb file, I have:

resources :users, only: [:show, :edit, :update]
devise_for :users, :controllers => { :registrations => 'registrations', :confirmations => 'confirmations' }, :path => '', :path_names => { :sign_in => "login", :sign_up => "request_invite" }

Edit – response to Viktor’s comment:

I did change the User help to:

def resource
  @resource ||= User.find(params[:id])
end

So, per the API docs, this should also have picked up /users/:id as an action, so, the HTML should now look like this:

<form id="edit_user_1" class="edit_user" method="post" action="/users/1" accept-charset="UTF-8">

Instead, it is:

<form id="edit_user" class="edit_user" method="post" action="/users/user" accept-charset="UTF-8">

So, when the User controller steps into action, the following code is hit:

def update
  @user = User.find(params[:id])

and it thinks that (fron the form’s action), that the id I’m passing is the word user, so I’m expecting to get the following error message when I click on update:

Couldn’t find User with id=user

and that’s exactly what I’m getting as an error. Any additional insight?

Final Answer:

In users_helper.rb:

def resource
  @resource ||= User.find(params[:id])
end

and in users/edit.html.erb

resource_name, :html => { :method => :put }) do |f| %>

  • 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-05T06:33:30+00:00Added an answer on June 5, 2026 at 6:33 am

    short answer is: it depends on the value of resource in your view.

    http://apidock.com/rails/v3.2.3/ActionView/Helpers/FormHelper/apply_form_for_options!
    the ids and classes for form are generated by the dom_id and dom_class helpers, the ‘action’ prefix being ‘edit’ and not ‘new’ if and only if:

    object.respond_to?(:persisted?) && object.persisted?
    

    for an activerecord object, this evaluates to true if and only if the object has ever been saved to db.

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

Sidebar

Related Questions

Here's the method. I want to know if I am violating any best practices
Here's the basic setup: I have a thin bar at the top of a
Here is my problem : I have a post controller with the action create.
Here is an example: I write html code inside of textarea, then I swap
Here's what I'm trying to accomplish with this program: a recursive method that checks
Here is an example: I have the generic type called Account. I wish to
Here is the problem that I am trying to solve. I have two folders
Here is my code...I have two dimensional matrices A,B. I want to develop the
here's what we have today: * NxM grid of points in 3D * we
Here is my code (Say we have a single button on the page that

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.