Skip to content

Instantly share code, notes, and snippets.

@kellydunn
Created November 2, 2010 05:34
Show Gist options
  • Save kellydunn/659286 to your computer and use it in GitHub Desktop.
Save kellydunn/659286 to your computer and use it in GitHub Desktop.
ye
def process_json_update(params)
if params[:update_action] == "create_resource"
resource = Resource.new(params[:resource])
resource.project_id = self.id
if resource.save
json = {:result => "success", :resource=>resource.attributes}
else
json = {:result => "failure", :errors=>"Could not save resource"}
end
elsif params[:update_action] == "delete_resource"
resource = Resource.find(params[:resource][:id])
if resource.destroy
json = {:result => "success", :resource=>resource.attributes}
else
json = {:resource => "failure", :errors=>"Could not delete resourc"}
end
elsif params[:update_action] == "assign_contact"
and then the rest of your code, untouched.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment