Created favorite job

parent 3d6a158c
Pipeline #1048 canceled with stages
in 0 seconds
class JobFavoritesController < ApplicationController class FavoriteJobsController < ApplicationController
before_action :sign_in_validation, only: %i[create destroy show] before_action :sign_in_favorite_validation, only: %i[create destroy]
before_action :sign_in_validation, only: [:show]
def show def show
@count = current_user.favorite_jobs.count @count = current_user.favorite_jobs.count
...@@ -32,10 +33,17 @@ class JobFavoritesController < ApplicationController ...@@ -32,10 +33,17 @@ class JobFavoritesController < ApplicationController
private private
def sign_in_validation def sign_in_favorite_validation
return if signed_in? return if signed_in?
session[:return_to] = request.referer session[:return_to] = request.referer
flash[:warning] = Settings.user.warning_signin flash[:warning] = Settings.user.warning_signin
redirect_to login_path redirect_to login_path
end end
def sign_in_validation
return if signed_in?
store_location
flash[:warning] = Settings.user.warning_signin
redirect_to login_path
end
end end
...@@ -21,9 +21,7 @@ ...@@ -21,9 +21,7 @@
<div class="salary col-3"> <div class="salary col-3">
Salary: <%= favorited_job.job.salary %> Salary: <%= favorited_job.job.salary %>
</div> </div>
<%= form_for(:job_favorite, url: unfavorite_job_path(job_id: favorited_job.job.id), method: :delete, remote: true) do |f| %> <%= link_to "Remove", unfavorite_job_path(job_id: favorited_job.job.id), method: :delete, remote: true, class: "btn btn-danger", id: "button-remove" %>
<%= f.submit "Remove", class: "btn btn-danger", id: "button-remove" %>
<% end %>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -3,7 +3,12 @@ ...@@ -3,7 +3,12 @@
<h1 class="text-center my-job-label">My Favorite Job (<span class="count-favorite-jobs"><%= @count %></span> jobs)</h1> <h1 class="text-center my-job-label">My Favorite Job (<span class="count-favorite-jobs"><%= @count %></span> jobs)</h1>
<%= paginate @favorited_jobs, outer_window: 2, window: 1 %> <%= paginate @favorited_jobs, outer_window: 2, window: 1 %>
<div class="favorite-page"> <div class="favorite-page">
<%= render partial: "job_favorites/my_favorite_jobs", collection: @favorited_jobs, as: :favorited_job %> <%= form_tag apply_job_path(job_id: params[:job_id]), method: :get, enforce_utf8: false do %>
<%= render partial: "favorite_jobs/my_favorite_jobs", collection: @favorited_jobs, as: :favorited_job %>
<div class="row justify-content-center">
<%= submit_tag 'Apply Job', name: nil, class: 'btn btn-lg btn-danger' %>
</div>
<% end %>
</div> </div>
<%= paginate @favorited_jobs, outer_window: 2, window: 1 %> <%= paginate @favorited_jobs, outer_window: 2, window: 1 %>
<% else %> <% else %>
......
...@@ -33,11 +33,11 @@ Rails.application.routes.draw do ...@@ -33,11 +33,11 @@ Rails.application.routes.draw do
get 'jobs/industry/:converted_name', to: 'jobs#industry_jobs', as: :industry_jobs get 'jobs/industry/:converted_name', to: 'jobs#industry_jobs', as: :industry_jobs
get 'jobs/company/:converted_name', to: 'jobs#company_jobs', as: :company_jobs get 'jobs/company/:converted_name', to: 'jobs#company_jobs', as: :company_jobs
post 'favorite_job', to: 'job_favorites#create', as: :favorite_job post 'favorite_job', to: 'favorite_jobs#create', as: :favorite_job
delete 'unfavorite_job', to: 'job_favorites#destroy', as: :unfavorite_job delete 'unfavorite_job', to: 'favorite_jobs#destroy', as: :unfavorite_job
get 'favorite', to: 'job_favorites#show', as: :my_favorite_job get 'favorite', to: 'favorite_jobs#show', as: :my_favorite_job
resources :job_favorites, only: [:create, :destroy] resources :favorite_jobs, only: [:create, :destroy, :show]
resources :job_applieds,only: [:new, :create] resources :job_applieds,only: [:new, :create]
resources :reset_passwords, only: [:edit, :update] resources :reset_passwords, only: [:edit, :update]
resources :confirmations, only: [:new] resources :confirmations, only: [:new]
......
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