jquery - Rails AJAX Missing Template Error with link_to Delete -


i trying ajax-ify type app , finished dealing problem create method (see [here][1]). delete method acting up, can't use previous solution (moving remote: true submit form_for line) because deletion done via link_to.

here's tasks#index action:

  def index     @create_task = task.new     @tasks = task.all     @one_time = task.where(frequency: "onetime", completed: false, user_id: current_user.id)     @one_time_done = task.where(frequency: "onetime", completed: true, user_id: current_user.id)     @daily = task.where(frequency: "daily", completed: false, user_id: current_user.id)     @daily_done = task.where(frequency: "daily", completed: true, user_id: current_user.id)     @weekly = task.where(frequency: "weekly", completed: false, user_id: current_user.id)     @weekly_done = task.where(frequency: "weekly", completed: true, user_id: current_user.id)     @monthly = task.where(frequency: "monthly", completed: false, user_id: current_user.id)     @monthly_done = task.where(frequency: "monthly", completed: true, user_id: current_user.id)   end 

and tasks#destroy action:

  def destroy     @one_time = task.where(frequency: "onetime", completed: false, user_id: current_user.id)     @one_time_done = task.where(frequency: "onetime", completed: true, user_id: current_user.id)     @daily = task.where(frequency: "daily", completed: false, user_id: current_user.id)     @daily_done = task.where(frequency: "daily", completed: true, user_id: current_user.id)     @weekly = task.where(frequency: "weekly", completed: false, user_id: current_user.id)     @weekly_done = task.where(frequency: "weekly", completed: true, user_id: current_user.id)     @monthly = task.where(frequency: "monthly", completed: false, user_id: current_user.id)     @monthly_done = task.where(frequency: "monthly", completed: true, user_id: current_user.id)      if @task.destroy         respond_to |format|           format.js           format.html       end     else       flash[:warning] = "oops! went wrong!"     end    end   [1]: https://stackoverflow.com/questions/45667684/ajax-with-rails-missing-template 

here delete link_to (from partial):

   <%= link_to task_path(task), method: :delete, remote: true %>         <i class="icon ion-close-circled" id=(task.id + "task") style="margin-left: 5px"></i>    <% end %> 

rendered on tasks/index.html.erb so:

<div id="onetime-todo"><%= render partial: 'items', locals: { task: @one_time } %></div> 

here's delete.js.erb:

$("#onetime-todo").html("<%= escape_javascript(render partial: 'items', locals: { task: @one_time }) %>") $("#onetime-done").html("<%= escape_javascript(render partial: 'done', locals: { task: @one_time_done }) %>")  $("#daily-todo").html("<%= escape_javascript(render partial: 'items', locals: { task: @daily }) %>") $("#daily-done").html("<%= escape_javascript(render partial: 'done', locals: { task: @daily_done }) %>")  $("#weekly-todo").html("<%= escape_javascript(render partial: 'items', locals: { task: @weekly }) %>") $("#weekly-done").html("<%= escape_javascript(render partial: 'done', locals: { task: @weekly_done }) %>")  $("#monthly-todo").html("<%= escape_javascript(render partial: 'items', locals: { task: @monthly }) %>") $("#monthly-done").html("<%= escape_javascript(render partial: 'done', locals: { task: @monthly_done }) %>") 

and irritating server log:

started delete "/tasks/1" ::1 @ 2017-08-14 12:59:40 -0700 processing taskscontroller#destroy js   parameters: {"id"=>"1"}   task load (0.1ms)  select  "tasks".* "tasks" "tasks"."id" = ? limit 1  [["id", 1]]   user load (0.1ms)  select  "users".* "users" "users"."id" = ?  order "users"."id" asc limit 1  [["id", 1]]    (0.1ms)  begin transaction   sql (0.4ms)  delete "tasks" "tasks"."id" = ?  [["id", 1]]    (0.6ms)  commit transaction completed 500 internal server error in 15ms (activerecord: 1.3ms)  actionview::missingtemplate - missing template tasks/destroy, application/destroy {:locale=>[:en], :formats=>[:js, :html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee]}. searched in:   * "/users/lizbayardelle/dropbox/code/fam/app/views"   * "/users/lizbayardelle/.rvm/gems/ruby-2.3.3/gems/ckeditor-4.2.2/app/views"   * "/users/lizbayardelle/.rvm/gems/ruby-2.3.3/gems/devise-4.2.0/app/views" : 

it bothers me error keeps occurring each method. deletion happen, necessitates refresh appear on page. see what's happening here?

you want delete.js.erb destroy.js.erb since action destroy, not delete.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -