Commit b17d7178 by Thanh Hung Pham

Remove favorite jobs

parent 068e93ee
......@@ -2,7 +2,7 @@ $(function() {
$( ".favorite_add" ).on( "click", function() {
$.ajax({
url: "/jobs/favorite",
type: "POST",
type: "GET",
data: {"job_id" : $("#job_id").val()},
dataType: "json",
success: function(data) {
......@@ -14,7 +14,7 @@ $(function() {
$(".favorite_remove").on("click", function() {
$.ajax({
url: "/jobs/favorite_remove",
type: "POST",
type: "GET",
data: {"job_id" : $("#job_id").val()},
dataType: "json",
success: function(data) {
......
......@@ -26,7 +26,7 @@ class JobsController < ApplicationController
def favorite_remove
job = Job.find(params[:job_id])
Favorite.where(user: current_user, job: job).destroy
Favorite.where(user: current_user, job: job).destroy_all
end
def favorited_jobs
......
......@@ -8,9 +8,7 @@ Rails.application.routes.draw do
get 'jobs/applied_jobs', to: 'jobs#applied_jobs'
get 'jobs/show/', to: 'jobs#show'
get 'jobs/favorite', to: 'jobs#favorite'
post 'jobs/favorite', to: 'jobs#favorite'
get 'jobs/favorite_remove', to: 'jobs#favorite_remove'
post 'jobs/favorite_remove', to: 'jobs#favorite_remove'
get 'jobs/favorited_jobs', to: 'jobs#favorited_jobs'
get 'jobs/history_jobs', to: 'jobs#history_jobs'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment