<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content=text/html;charset=iso-8859-1>
<META content="MSHTML 6.00.6000.16735" name=GENERATOR></HEAD>
<BODY id=MailContainerBody
style="PADDING-RIGHT: 10px; PADDING-LEFT: 10px; PADDING-TOP: 15px"
bgColor=#ffffff leftMargin=0 topMargin=0 CanvasTabStop="true"
name="Compose message area">
<DIV><FONT face=Arial size=2>Hi,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I'm a bit of a lurker, and have recently taken up
Rails again. I am experimenting with a standard controller for a simple
model and have used the new RESTful stuff, and therefore have map.resources
<mymodel> in the routes.rb file.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>This gives rise to new, edit, update and create as
standard actions for this model.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Then I read in Rails Recipes an item to consolidate
these into one functio of the controller. Only it doesn't quite
work. The basics are to do two checks:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>@it = MyModel.find_by_id( params[:id] ) ¦¦
MyModel.new</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>if request.post?</FONT></DIV>
<DIV> <FONT face=Arial size=2>... including save with
params[:it]</FONT></DIV>
<DIV><FONT face=Arial size=2>end</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>With the update action, post? is not true.
Viewing the source, the form_for (@it) is generating /my_models as the
destination and "post" as the method in the form html element. Checking
the server console output, I see it gets a URL with "PUT" as the HTTP
verb.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Anyone else seen that, or am I missing something
daft?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>TIA,</FONT></DIV>
<DIV><FONT face=Arial size=2>Simon</FONT></DIV></BODY></HTML>