Skip to content

Scaffold edit form submits POST instead of PATCH/PUT, causing route error #2433

@zainforbjs

Description

@zainforbjs

Describe the bug
When generating a scaffold using the Wheels CLI, the generated form for the edit page submits using the POST method instead of the expected PATCH or PUT.
This results in a routing error because the /posts/:id route does not accept POST for updates.

To Reproduce
Steps to reproduce the behavior:

  1. Generate scaffold:
wheels generate scaffold Post title:string body:text
  1. Start the application
  2. Create a post
  3. Open edit page:
http://localhost:2000/posts/2/edit
  1. Submit the form
  2. Observe routing error

Generated form behavior
New (works correctly):

<form action="/posts" method="post">

Edit (problematic):

<form action="/posts/2" method="post">

Error message:

Wheels.RouteNotFound  
Incorrect HTTP Verb for route  
The posts/2 path does not allow POST requests, only GET,PATCH,PUT,DELETE,GET requests.

Template used (_form.cfm):

#startFormTag(action=IsNumeric(post.id ?: "") ? "update" : "create", key=post.id ?: "")#

Expected behavior

  • Edit form should submit using:
    • PATCH or PUT (via method override or proper form configuration)
  • Generated scaffold should work out-of-the-box with RESTful routes

Example expected output:

<form action="/posts/2" method="post">
    <input type="hidden" name="_method" value="PATCH">

Actual behavior

  • Edit form submits as plain POST
  • No method override (_method) is included
  • Results in route mismatch error

Desktop:

  • OS: Any

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions