Commit 8b8b6c22

mo khan <mo@mokhan.ca>
2014-09-24 02:30:56
add delete button to jobs.
1 parent c1393fe
Changed files (3)
app
controllers
views
admin
config
app/controllers/admin/jobs_controller.rb
@@ -12,5 +12,11 @@ module Admin
     def show
       @job = @repository.find(params[:id])
     end
+
+    def destroy
+      @job = @repository.find(params[:id])
+      @job.destroy
+      redirect_to admin_jobs_path
+    end
   end
 end
app/views/admin/jobs/index.html.erb
@@ -30,6 +30,7 @@
             <td><%= time_ago_in_words(job.locked_at) if job.locked_at %></td>
             <td><%= time_ago_in_words(job.created_at) %></td>
             <td><%= time_ago_in_words(job.updated_at) %></td>
+            <td><%= link_to "Destroy", admin_job_path(job), method: :delete, class: 'btn btn-danger' %></td>
           </tr>
         <% end %>
       </tbody>
config/routes.rb
@@ -72,7 +72,7 @@ Cake::Application.routes.draw do
   namespace :admin do
     root :to => "users#index"
     resources :users, only: [:index, :show]
-    resources :jobs, only: [:index, :show]
+    resources :jobs, only: [:index, :show, :destroy]
     resources :activities, only: [:index]
     resources :subscriptions, only: [:index]
     resources :photos, only: [:index, :show]