Commit 34c4d0c6 by Tô Ngọc Ánh

fix redirect link after signin, check is_applied_job in detail job

parent a772e138
Pipeline #967 canceled with stages
in 0 seconds
...@@ -12,8 +12,8 @@ class AppliedJobsController < ApplicationController ...@@ -12,8 +12,8 @@ class AppliedJobsController < ApplicationController
@applied_job = current_user.applied_jobs.new(applied_job_params) @applied_job = current_user.applied_jobs.new(applied_job_params)
@applied_job.curriculum_vitae = current_user.curriculum_vitae if params[:applied_job][:curriculum_vitae].nil? @applied_job.curriculum_vitae = current_user.curriculum_vitae if params[:applied_job][:curriculum_vitae].nil?
if @applied_job.invalid? if @applied_job.invalid?
flash[:error] = @applied_job.errors.full_messages flash.now[:error] = @applied_job.errors.full_messages
redirect_to new_applied_job_path(job_id: @applied_job.job_id) render :new
end end
end end
...@@ -24,7 +24,7 @@ class AppliedJobsController < ApplicationController ...@@ -24,7 +24,7 @@ class AppliedJobsController < ApplicationController
AppliedJobMailer.with(applied_job: @applied_job).success_email.deliver_later AppliedJobMailer.with(applied_job: @applied_job).success_email.deliver_later
else else
flash[:error] = @applied_job.errors.full_messages flash[:error] = @applied_job.errors.full_messages
redirect_to new_applied_job_path(job_id: @applied_job.job_id) render :new
end end
end end
......
...@@ -9,5 +9,6 @@ class JobsController < ApplicationController ...@@ -9,5 +9,6 @@ class JobsController < ApplicationController
def show def show
@job = Job.find_by(id: params[:id]) @job = Job.find_by(id: params[:id])
@is_not_applied = user_signed_in? ? current_user.applied_jobs.find_by(job_id: @job.id).blank? : true
end end
end end
...@@ -26,6 +26,6 @@ class Users::SessionsController < Devise::SessionsController ...@@ -26,6 +26,6 @@ class Users::SessionsController < Devise::SessionsController
# end # end
def after_sign_in_path_for(resource) def after_sign_in_path_for(resource)
my_page_path #your path stored_location_for(resource) || my_page_path
end end
end end
...@@ -31,15 +31,16 @@ ...@@ -31,15 +31,16 @@
<%= @job.description.html_safe %> <%= @job.description.html_safe %>
</div> </div>
<div class="col-2"> <div class="col-2">
<% is_not_applied = user_signed_in? ? current_user.applied_jobs.find_by(job_id: @job.id).blank? : true %> <%= link_to_if @is_not_applied, 'Apply Now', new_applied_job_path(job_id: @job.id), class: 'btn btn-outline-success btn-lg' do %>
<%= link_to_if is_not_applied, 'Apply Now', new_applied_job_path(job_id: @job.id), class: 'btn btn-outline-success btn-lg' do %>
<%= link_to 'Apply Now', '#', class: 'btn btn-outline-secondary btn-lg disabled' %> <%= link_to 'Apply Now', '#', class: 'btn btn-outline-secondary btn-lg disabled' %>
<% end %> <% end %>
</div> </div>
</div> </div>
<div class="row my-3"> <div class="row my-3">
<div class="col-6 text-right"> <div class="col-6 text-right">
<%= link_to 'Apply Now', new_applied_job_path(job_id: @job.id), class: 'btn btn-outline-success btn-lg' %> <%= link_to_if @is_not_applied, 'Apply Now', new_applied_job_path(job_id: @job.id), class: 'btn btn-outline-success btn-lg' do %>
<%= link_to 'Apply Now', '#', class: 'btn btn-outline-secondary btn-lg disabled' %>
<% end %>
</div> </div>
<div class="col-6 text-left"> <div class="col-6 text-left">
<%= link_to 'Favorite', '#', class: 'btn btn-outline-danger btn-lg' %> <%= link_to 'Favorite', '#', class: 'btn btn-outline-danger btn-lg' %>
......
# Load the Rails application. # Load the Rails application.
require_relative 'application' require_relative 'application'
# disable auto add field_with_errors class
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
html_tag.html_safe
end
# Initialize the Rails application. # Initialize the Rails application.
Rails.application.initialize! Rails.application.initialize!
Rails.application.routes.draw do Rails.application.routes.draw do
devise_for :users, controllers: { sessions: 'users/sessions', registrations: 'users/registrations' }
root to: 'home#index' root to: 'home#index'
devise_for :users, controllers: { sessions: 'users/sessions', registrations: 'users/registrations' }
get 'cities', to: 'locations#index' get 'cities', to: 'locations#index'
get 'industries', to: 'industries#index' get 'industries', to: 'industries#index'
get 'detail/:id', to: 'jobs#show', as: :job get 'detail/:id', to: 'jobs#show', as: :job
get 'jobs/:model/:slug', to: 'jobs#index', as: :jobs get 'jobs/:model/:slug', to: 'jobs#index', as: :jobs
get 'my', to: 'users#my_page', as: :my_page get 'my', to: 'users#my_page', as: :my_page
resources :users, only: :show resources :users, only: :show
get 'apply', to: 'applied_jobs#new', as: :new_applied_job get 'apply', to: 'applied_jobs#new', as: :new_applied_job
post 'confirm', to: 'applied_jobs#confirm', as: :confirm_applied_job post 'confirm', to: 'applied_jobs#confirm', as: :confirm_applied_job
post 'finish', to: 'applied_jobs#finish', as: :finish_applied_job post 'finish', to: 'applied_jobs#finish', as: :finish_applied_job
......
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