Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rails RESTful updates

In Rails, should you be able to update a field using a URL. Is that called RESTful?

For example, should something similar to this work to update workorder.wostatus_id for workorder with id=2?

http://localhost:5000/workorders/2?wostatus_id=4

Thanks!

like image 750
Reddirt Avatar asked Nov 24 '25 18:11

Reddirt


1 Answers

In the case you've provided that shouldn't work as updates should be performed via a PUT request although if the URL was requested via PUT then it should work.

Remember the idea is that:

  • GET to access and retrieve data
  • PUT to update data
  • POST to create data
  • DELETE to remove data

EDIT: Often the actual parameter names can vary depending on the controller implementation so in rails you often find ?workorder[wostatus_id]=4, where it will reference the model name.

like image 179
Darren Coxall Avatar answered Nov 27 '25 12:11

Darren Coxall