Newbie: Why doe New work but edit/update not?

Michael B. wrote:

try sticking with <% form_for(@user) do |f| %>

If I go with that I’m back to the original problem. No errors and it
just doesn’t write changes to the database.

The Logfile has the following entries for the attempted edit…

Processing UsersController#edit (for IPADDRESS at 2008-06-05 13:31:58)
[GET]
Session ID:
BAh7BzoMY3NyZl9pZCIlM2RkOTljMTk3YzE2MWQwMTY3MTNhN2NlZTc5OTFm%0ANWIiCmZsYXNoSUM6J0FjdGlvbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhh%0Ac2h7AAY6CkB1c2VkewA%3D–92ba3187f08e3b00058aa442cdf467c0efde5102
Parameters: {“action”=>“edit”, “id”=>“1222”, “controller”=>“users”}
e[4;36;1mUser Columns (0.013465)e[0m e[0;1mSHOW FIELDS FROM
userse[0m
e[4;35;1mUser Load (0.011432)e[0m e[0mSELECT * FROM users WHERE
(users.id = ‘1222’) e[0m
Rendering template within layouts/users
Rendering users/edit
Completed in 0.10657 (9 reqs/sec) | Rendering: 0.05074 (47%) | DB:
0.02490 (23%) | 200 OK [http://www.met.rdg.ac.uk/users/users/1222/edit]

Processing UsersController#index (for IPADDRESS at 2008-06-05 13:32:04)
[PUT]
Session ID:
BAh7BzoMY3NyZl9pZCIlM2RkOTljMTk3YzE2MWQwMTY3MTNhN2NlZTc5OTFm%0ANWIiCmZsYXNoSUM6J0FjdGlvbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhh%0Ac2h7AAY6CkB1c2VkewA%3D–92ba3187f08e3b00058aa442cdf467c0efde5102
Parameters: {“user”=>{“SurName”=>“test 3”, “Title”=>“Mr”,
“EMail”=>“[email protected]”, “ForeName”=>“Donny”,
“RoomNo”=>“3F546”}, “commit”=>“Save”,
“authenticity_token”=>“tokendigits”, “_method”=>“put”,
“action”=>“index”, “controller”=>“users”}
e[4;36;1mUser Load (0.280259)e[0m e[0;1mSELECT * FROM users e[0m
Rendering template within layouts/users
Rendering users/index
e[4;35;1mUser Columns (0.013465)e[0m e[0mSHOW FIELDS FROM
userse[0m
Completed in 0.99386 (1 reqs/sec) | Rendering: 0.51505 (51%) | DB:
0.29372 (29%) | 200 OK [http://www.website.com/users/users/]

The urls are not correct: http://www.met.rdg.ac.uk/users/users/1222/edit

Earlier I suggested that you look at the html rendered by your
templates (view source in your browser or firebug). For whatever
reason the action on your forms is not correct.

The edit action should be posting to the update action, not index
action.

Check the html output for your edit page. The form tag should look
something like this:

perhaps somebody can post an example ActionController that works along
with an example routes.rb file/correct urls so I can figure out my next
step?

Most of the tutorials for this stuff seem to be for rails 1.2

Michael B. wrote:

The edit action should be posting to the update action, not index
action.

Check the html output for your edit page. The form tag should look
something like this:

Interesting, the page source seems to have left the ID out so I’m
getting

instead of

Shouldn’t

<% form_for(@user) do |f| %>

<%= f.submit “Save” %>

<% End %>

do this automatically?

Michael B. wrote:

create a dummy project and then run script/generate scaffold User
first_name:string last_name:string

that will give you a good example RESTful controller. easier than
someone posting that code.

This is getting weird now. I’ve done the following

rails testproj
script/generate scaffold user ForeName:string SurName:string

and the generated UsersController code for update and delete is
identical to what I have for my user project, and the only difference
inthe routes.rb file is the line, map.root :controller => “users”

I’m kind of at a loss :frowning:

If my database was not allowing update access it rails would throw an
exception wouldn’t it?

create a dummy project and then run script/generate scaffold User
first_name:string last_name:string

that will give you a good example RESTful controller. easier than
someone posting that code.