CSC/ECE 517 Spring 2013/ch1a 1b mh

From Expertiza_Wiki
Revision as of 21:42, 7 February 2013 by Mlhall3 (talk | contribs)
Jump to navigation Jump to search

Ruby CRUD - Update and Destroy

Introduction

Edit


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)

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)