Cant delete record

depassion
depassion used Ask the Experts™
on
i cant destroy a record

ruby-1.9.2-p180 :011 > item
 => #<Item id: 40, number: 79, title: "8c07cc84fe31652b3b55", description: "18c0c74735e5133c5babb622a10ed3f608086e17", price: "140/100", created_at: "2011-08-05 13:13:12", updated_at: "2011-08-05 13:13:12", category_id: 4>

ruby-1.9.2-p180 :012 > item.destroy
 => #<Item id: 40, number: 79, title: "8c07cc84fe31652b3b55", description: "18c0c74735e5133c5babb622a10ed3f608086e17", price: "140/100", created_at: "2011-08-05 13:13:12", updated_at: "2011-08-05 13:13:12", category_id: 4>
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
this is the development server output when i try to delete a record

 AREL (0.4ms)  DELETE FROM "items" WHERE "items"."id" = 39


Started GET "/items/20" for 127.0.0.1 at 2011-08-06 10:59:27 +0200

AbstractController::ActionNotFound (The action 'show' could not be found for ItemsController):

Author

Commented:
a successful destroy output should look like this:

Started DELETE "/transactions/3" for 127.0.0.1 at 2011-08-06 11:06:03 +0200
  Processing by TransactionsController#destroy as HTML
  Parameters: {"authenticity_token"=>"FNi4GDXZGn3yJNXZanNZ3J/vggiMeR7zb/hpmf66s3U=", "id"=>"3"}
  Transaction Load (0.1ms)  SELECT "transactions".* FROM "transactions" WHERE "transactions"."id" = ? LIMIT 1  [["id", "3"]]
  SQL (0.4ms)  DELETE FROM "transactions" WHERE "transactions"."id" = ?  [["id", 3]]
Redirected to http://localhost:3000/transactions
Completed 302 Found in 14ms

Commented:
Check your routes:
   rake routes
there may be a problem there which is sending the code to items/show
Expert Spotlight: Joe Anderson (DatabaseMX)

We’ve posted a new Expert Spotlight!  Joe Anderson (DatabaseMX) has been on Experts Exchange since 2006. Learn more about this database architect, guitar aficionado, and Microsoft MVP.

Author

Commented:
i think routes are ok:

Viking::Application.routes.draw do
 
  resources :items, :sessions, :categories

  # The priority is based upon order of creation:
  # first created -> highest priority.

  # Sample of regular route:
  match 'login' => 'sessions#new', :as => :login
  match 'logout' => 'sessions#destroy', :as => :logout
  match 'menu' => 'items#index'
 .........
root :to => "items#index"
end
Commented:
Check your versions for prototype.js and rails.js... there was a bug reported last year that caused something similar to this:
     https://rails.lighthouseapp.com/projects/8994/tickets/4013-link_to-with-method-doesnt-work
also:
     http://www.ruby-forum.com/topic/205300

Author

Commented:
ok, my bad. didn't realize that i needed jQuery. I removed prototype just after i generated the app and didn't replace it.

Commented:
NP. Glad that worked... and thanks for the points!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial