Note that there are some explanatory texts on larger screens.

plurals
  1. PORails 3 form uses "edit" instead of "update" when the form is submitted
    primarykey
    data
    text
    <p>I have a problem with my form in Rails 3. The forms work if I create something, but if I try to update something, they fail. In this exmaple I tried to update the user settings, like name, mail etc. Here are the relevant code snippets:</p> <p>Edit and Update from User_Controller.rb</p> <pre><code> def edit @title = "Nutzerverwaltung" end def update @user = User.find(params[:id]) if @user.update_attributes(params[:user]) flash[:success] = "Profil aktualisiert" redirect_to @user else @title = "Edit" render 'edit' end end </code></pre> <p>Then, there is the form:</p> <pre><code>%form.user_edit = form_for @user, :url =&gt; {:controller =&gt; "users", :action =&gt; "update"}, :html =&gt; { :method =&gt; :put } do |f| = render 'shared/error_messages', :object =&gt; f.object = render 'fields', :f =&gt; f .actions = f.submit "Update" </code></pre> <p>My terminal output when running the local WEBrick Server (some of the form labels have german names):</p> <pre><code>Started GET "/users/2/edit?utf8=%E2%9C%93&amp;_method=put&amp;authenticity_token=R5LfeIAjpJOpH%2B0yMD8PLO24%2Fgcct0CCqXuzoLoVibs%3D&amp;user%5Banrede%5D=&amp;user%5Bname%5D=Johnny&amp;user%5Bemail%5D=t.schneider%40mail.com&amp;user%5Bpassword%5D=&amp;user%5Bpassword_confirmation%5D=&amp;user%5Bplz%5D=&amp;user%5Bort%5D=&amp;user%5Bstrasse%5D=&amp;commit=Update" for 127.0.0.1 at 2011-09-13 15:53:24 +0200 Processing by UsersController#edit as HTML Parameters: {"utf8"=&gt;"✓", "authenticity_token"=&gt;"R5LfeIAjpJOpH+0yMD8PLO24/gcct0CCqXuzoLoVibs=", "user"=&gt;{"anrede"=&gt;"", "name"=&gt;"TESTer", "email"=&gt;"t.schneider@mail.com", "password"=&gt;"[FILTERED]", "password_confirmation"=&gt;"[FILTERED]", "plz"=&gt;"", "ort"=&gt;"", "strasse"=&gt;""}, "commit"=&gt;"Update", "id"=&gt;"2"} User Load (1.2ms) SELECT "users".* FROM "users" WHERE ("users"."id" = 2) LIMIT 1 CACHE (0.0ms) SELECT "users".* FROM "users" WHERE ("users"."id" = 2) LIMIT 1 Rendered shared/_error_messages.html.haml (2.2ms) Rendered users/_fields.html.haml (7.5ms) Rendered layouts/_stylesheets.html.haml (2.4ms) Rendered layouts/_header.html.haml (3.9ms) Rendered layouts/_footer.html.haml (2.0ms) Rendered users/edit.html.haml within layouts/application (33.2ms) Completed 200 OK in 118ms (Views: 36.7ms | ActiveRecord: 1.2ms) </code></pre> <p>And then there is my rake routes, which seems ok for me:</p> <pre><code> users GET /users(.:format) {:action=&gt;"index", :controller=&gt;"users"} users POST /users(.:format) {:action=&gt;"create", :controller=&gt;"users"} new_user GET /users/new(.:format) {:action=&gt;"new", :controller=&gt;"users"} edit_user GET /users/:id/edit(.:format) {:action=&gt;"edit", :controller=&gt;"users"} user GET /users/:id(.:format) {:action=&gt;"show", :controller=&gt;"users"} user PUT /users/:id(.:format) {:action=&gt;"update", :controller=&gt;"users"} user DELETE /users/:id(.:format) {:action=&gt;"destroy", :controller=&gt;"users"} sessions POST /sessions(.:format) {:action=&gt;"create", :controller=&gt;"sessions"} new_session GET /sessions/new(.:format) {:action=&gt;"new", :controller=&gt;"sessions"} session DELETE /sessions/:id(.:format) {:action=&gt;"destroy", :controller=&gt;"sessions"} posts POST /posts(.:format) {:action=&gt;"create", :controller=&gt;"posts"} edit_post GET /posts/:id/edit(.:format) {:action=&gt;"edit", :controller=&gt;"posts"} post DELETE /posts/:id(.:format) {:action=&gt;"destroy", :controller=&gt;"posts"} root /(.:format) {:controller=&gt;"pages", :action=&gt;"start"} /(.:format) {:controller=&gt;"pages", :action=&gt;"start"} start /start(.:format) {:controller=&gt;"pages", :action=&gt;"start"} kontakt /kontakt(.:format) {:controller=&gt;"pages", :action=&gt;"kontakt"} tagebuch /tagebuch(.:format) {:controller=&gt;"pages", :action=&gt;"tagebuch"} hinzufuegen /hinzufuegen(.:format) {:controller=&gt;"pages", :action=&gt;"hinzufuegen"} bluefocus /bluefocus(.:format) {:controller=&gt;"pages", :action=&gt;"bluefocus"} seminare /seminare(.:format) {:controller=&gt;"pages", :action=&gt;"seminare"} angebote /angebote(.:format) {:controller=&gt;"pages", :action=&gt;"angebote"} specials /specials(.:format) {:controller=&gt;"pages", :action=&gt;"specials"} shop /shop(.:format) {:controller=&gt;"pages", :action=&gt;"shop"} registrieren /registrieren(.:format) {:controller=&gt;"users", :action=&gt;"registrieren"} login /login(.:format) {:controller=&gt;"sessions", :action=&gt;"login"} logout /logout(.:format) {:controller=&gt;"sessions", :action=&gt;"destroy"} /posts/:id/edit(.:format) {:controller=&gt;"posts", :action=&gt;"edit"} </code></pre> <p>I know that this function of editing was working once, but i don't know what changed, so that it doesn't work anymore.</p> <p>If you need anymore information just say a word.</p> <p>Every help is welcome. Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload