Skip to content

Instantly share code, notes, and snippets.

@nolman
Created March 21, 2011 14:44
Show Gist options
  • Save nolman/879548 to your computer and use it in GitHub Desktop.
Save nolman/879548 to your computer and use it in GitHub Desktop.
class AccountsController < ApplicationController
before_filter :require_user
def destroy
@account = current_user.accounts.find(params[:id])
@account.destroy
respond_to do |format|
format.html { redirect_to(accounts_url) }
format.xml { head :ok }
end
end
end
<!DOCTYPE html>
<html>
<head>
<title>This page issues a get request</title>
</head>
<body>
<h1>Here's a harmless image request.</h1>
<img src='http://localhost:3000/accounts/destroy/2'>
</body>
</html>
Started GET "/accounts/destroy/2" for 127.0.0.1 at 2011-03-21 07:40:49 -0700
Processing by AccountsController#destroy as
Parameters: {"id"=>"2"}
Redirected to http://localhost:3000/session/new
Completed 302 Found in 51ms
Started GET "/accounts/destroy/2" for 127.0.0.1 at 2011-03-21 07:45:21 -0700
ActionController::RoutingError (No route matches "/accounts/destroy/2"):
Started GET "/accounts/destroy/2" for 127.0.0.1 at 2011-03-21 07:41:23 -0700
Processing by AccountsController#destroy as
Parameters: {"id"=>"2"}
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."persistence_token" = 'cf772157f7f3531722557ce7403ff8d6dfed491de0c222b6f32156bc38c9e549d9b88677831210bc8d557e658c6eedd887afa1a7be7d64133ad81fdf2965da47' LIMIT 1
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
Account Load (0.3ms) SELECT "accounts".* FROM "accounts" WHERE "accounts"."id" = 2 AND ("accounts".owner_id = 1) LIMIT 1
AREL (0.4ms) DELETE FROM "accounts" WHERE "accounts"."id" = 2
Redirected to http://localhost:3000/accounts
Completed 302 Found in 83ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment