ruby on rails - iteration E3 | The action 'destroy' could not be found for CartsController -


hello all

i'm studying agile web development rails 4 currently.

here's clean cart (iteration e3).

1.to add button_to in views/cart/show.html.erb

<%= button_to 'empty cart', @cart, method: :delete, data: { confirm: 'are sure?' } %> 

2.to add method destroy in controllers/carts_controller.rb

def destroy   @cart.destroy if @cart.id == session[:cart_id]   session[:cart_id] = nil   respond_to |format|     format.html { redirect_to store_url, notice: 'your cart empty' }     format.json { head :no_content }   end end 

3.when click on empty cart button, got error message "the action 'destroy' not found cartscontroller", have checked these code lot times.
wondering if there wrong else.
would please tell me how fix this?

routes.rb

depot::application.routes.draw   resources :line_items   resources :carts   "store/index"   resources :products   root 'store#index', as: 'store' end 

5 errors rake test, think it's related, don't know how.

1) error: cartscontrollertest#test_should_create_cart: abstractcontroller::actionnotfound: action 'create' not found cartscontroller     test/controllers/carts_controller_test.rb:21:in `block (2 levels) in <class:cartscontrollertest>'     test/controllers/carts_controller_test.rb:20:in `block in <class:cartscontrollertest>'    2) error: cartscontrollertest#test_should_destroy_cart: abstractcontroller::actionnotfound: action 'destroy' not found cartscontroller     test/controllers/carts_controller_test.rb:45:in `block (2 levels) in <class:cartscontrollertest>'     test/controllers/carts_controller_test.rb:43:in `block in <class:cartscontrollertest>'    3) error: cartscontrollertest#test_should_get_index: actionview::template::error: undefined method `each' nil:nilclass     app/views/carts/index.html.erb:13:in `_app_views_carts_index_html_erb__860143545109165463_70364136402640'     test/controllers/carts_controller_test.rb:9:in `block in <class:cartscontrollertest>'    4) error: cartscontrollertest#test_should_get_new: actionview::template::error: first argument in form cannot contain nil or empty     app/views/carts/_form.html.erb:1:in `_app_views_carts__form_html_erb___571452078619530506_70364136338580'     app/views/carts/new.html.erb:3:in `_app_views_carts_new_html_erb__717241531793059964_70364164357880'     test/controllers/carts_controller_test.rb:15:in `block in <class:cartscontrollertest>'    5) error: cartscontrollertest#test_should_update_cart: abstractcontroller::actionnotfound: action 'update' not found cartscontroller     test/controllers/carts_controller_test.rb:38:in `block in <class:cartscontrollertest>' 

try :

 <%= button_to "empty cart", {:controller => "carts",:action => 'destroy', :id => cart.id }, :method => :delete %> 

change view folder name carts.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -