CSC/ECE 517 Spring 2013/ch1a 1b mh: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 6: | Line 6: | ||
==CRUD== | |||
==Edit== | ===Edit/Update=== | ||
<pre> | <pre> | ||
Line 23: | Line 23: | ||
redirect_to object_path(@object) | redirect_to object_path(@object) | ||
</pre> | </pre> | ||
====Comparison of Update and Create Actions==== | |||
==Destroy== | ==Destroy== | ||
Line 39: | Line 41: | ||
redirect_to object_path(@object) | redirect_to object_path(@object) | ||
</pre> | </pre> | ||
==Pitfalls in MVC Design== | |||
==Migration to Service Oriented Architecture== | |||
==Summary== |
Revision as of 00:13, 8 February 2013
Ruby CRUD - Update and Destroy
Introduction
CRUD
Edit/Update
locate the object @object = Object.find params(:id) update it @object.update_attributes!(params[:param]) inform of successful update flash[:notice] go to the updated object redirect_to object_path(@object)
Comparison of Update and Create Actions
Destroy
locate the object @object = Object.find params(:id) destroy it @object.destroy inform of successful update flash[:notice] = "Object '#{@object.title}' deleted." go to the updated object redirect_to object_path(@object)