Commit 9f44af60 by nnnghia98

edit routes.rb

parent 8467f3e0
class JobsController < ApplicationController class JobsController < ApplicationController
before_action :authenticate_user!, only: [:apply, :confirm_apply, :finish_apply] before_action :authenticate_user!, only: [:apply, :confirm_apply, :finish_apply, :applied_jobs]
before_action :find_user, only: :apply_available before_action :find_user, only: :apply_available
def index def index
......
class Users::MyPagesController < ApplicationController class Users::MyPagesController < ApplicationController
before_action :authenticate_user!, only: [:show, :applied_jobs] before_action :authenticate_user!, only: [:show]
def show def show
end end
def applied_jobs def applied_jobs
@applied_jobs = current_user.jobs.all.includes(:cities).decorate @applied_jobs = current_user.jobs.includes(:cities).decorate
end end
end end
...@@ -6,5 +6,5 @@ ...@@ -6,5 +6,5 @@
<h3>My CV: <%= current_user.cv_path %></h3> <h3>My CV: <%= current_user.cv_path %></h3>
<%= link_to "Edit", edit_user_registration_path, class: "btn btn-lg btn-primary" %> <%= link_to "Edit", edit_user_registration_path, class: "btn btn-lg btn-primary" %>
<%= link_to "My jobs", jobs_users_my_page_path, class: "btn btn-lg btn-primary" %> <%= link_to "My jobs", applied_jobs_users_my_page_path, class: "btn btn-lg btn-primary" %>
</div> </div>
<h1>Applied jobs</h1>
<%= render partial: "jobs/job", collection: @applied_jobs %>
...@@ -2,9 +2,12 @@ Rails.application.routes.draw do ...@@ -2,9 +2,12 @@ Rails.application.routes.draw do
resources :companies, only: :index resources :companies, only: :index
resources :industries, only: :index resources :industries, only: :index
resources :cities, only: :index resources :cities, only: :index
resources :jobs, only: [:index, :show] resources :jobs, only: [:index, :show] do
get "jobs/city/:city_id", to: "jobs#index", as: :city_jobs collection do
get "jobs/industry/:industry_id", to: "jobs#index", as: :industry_jobs get "city/:city_id", action: :index, as: :city
get "industry/:industry_id", action: :index, as: :industry
end
end
get "apply", to: "jobs#apply" get "apply", to: "jobs#apply"
get "confirm", to: "jobs#confirm_apply" get "confirm", to: "jobs#confirm_apply"
post "done", to: 'jobs#finish_apply' post "done", to: 'jobs#finish_apply'
...@@ -12,7 +15,9 @@ Rails.application.routes.draw do ...@@ -12,7 +15,9 @@ Rails.application.routes.draw do
root "tops#index" root "tops#index"
namespace :users do namespace :users do
resource :my_page, only: :show do resource :my_page, only: :show do
get "/jobs", to: "my_pages#applied_jobs" collection do
get "jobs", action: :applied_jobs, as: :applied_jobs
end
end end
end end
end end
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