ruby on rails - Delete Button Not Working - Not Sure What is Wrong -


all,

i tried this:

            <h9>thursday</h9>             <% @thursday.each |chorelist| %><br>                 <p2><%= chorelist.name %></p2>                 <%= button_to "delete", chorelists_destroy_path(:id, chorelist.id) %>             <% end %> 

it won't trick, however.

as can see, trying add delete button each iteration. missing here?

i'm still new rails, appreciated.

addendum: received error message when using latter method:

"couldn't find chorelist 'id'={:name=>"sweep floors", :day=>"sunday", :user_id=>2}"

i checked console, , parameters there.

  class savelistcontroller < applicationcontroller    before_filter :authenticate_user!    def index   @chorelist = chorelist.create(user_id: params[:user_id], chore_id:     params[:chore_id], day: params[:day], name: params[:chore_name])  redirect_to pick_chores_path  end   def display @chorelist = chorelist.all  @monday = @chorelist.where("day = 'monday'", user_id: current_user.id) @tuesday = @chorelist.where("day = 'tuesday'", user_id: current_user.id) @wednesday = @chorelist.where("day = 'wednesday'", user_id: current_user.id) @thursday = @chorelist.where("day = 'thursday'", user_id: current_user.id) @friday = @chorelist.where("day = 'friday'", user_id: current_user.id) @saturday = @chorelist.where("day = 'saturday'", user_id: current_user.id) @sunday = @chorelist.where("day = 'sunday'", user_id: current_user.id)    end   def destroy  @chorelist = chorelist.find(id: params[:id])  @chorelist.destroy  redirect_to show_chores_path  end  end 

rails.application.routes.draw do

resources :chorelists

get 'about' => 'welcome#about'

get 'contact' => 'welcome#contact'

root 'welcome#index'

get 'about' => 'welcome#about'

get 'pick_chores' => 'pick_chores#index'

post 'save_list' => 'save_list#index'

get 'show_chores' => 'save_list#display'

post 'chorelists_destroy' => 'save_list#destroy'

resources :chores devise_for :users

end

change :id, chorelist.id id: chorelist.id

<h9>thursday</h9> <% @thursday.each |chorelist| %><br>     <p2><%= chorelist.name %></p2>     <%= button_to "delete", chorelists_destroy_path(id: chorelist.id) %> <% end %> 

on controller

def destroy     @chorelist = chorelist.find(params[:id])     @chorelist.destroy     # things end 

Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -