create store_location

parent ca4676d4
Pipeline #1023 canceled with stages
in 0 seconds
......@@ -3,6 +3,8 @@ class JobAppliedsController < ApplicationController
before_action :find_job_id, only: [:new]
def new
founded_application = JobApplied.where(user_id: current_user.id, job_id: params[:job_id])
return redirect_to job_detail_path(params[:job_id]) if founded_application.present?
end
def show
......@@ -35,7 +37,8 @@ class JobAppliedsController < ApplicationController
def sign_in_validation
return if signed_in?
flash[:warning] = "Please Sign In..."
store_location
flash[:warning] = Settings.user.warning_signin
redirect_to login_path
end
......
......@@ -27,7 +27,8 @@ class JobsController < ApplicationController
end
def show
redirect_to jobs_path unless @job
return redirect_to jobs_path unless @job
@user = JobApplied.where(user_id: current_user.id, job_id: params[:id]) if signed_in?
end
private
......
......@@ -8,7 +8,7 @@ class SessionsController < ApplicationController
user = User.find_by(email: params[:session][:email].downcase)
if user && user.authenticate(params[:session][:password])
sign_in user
redirect_to my_page_path
redirect_back_or my_page_path
else
flash.now[:danger] = Settings.user.sign_in.failed
render 'new'
......
......@@ -40,6 +40,7 @@ class UsersController < ApplicationController
def sign_in_validation
return if signed_in?
store_location
flash[:warning] = Settings.user.warning_signin
redirect_to login_path
end
......
......@@ -27,4 +27,12 @@ module SessionsHelper
self.current_user = nil
end
def redirect_back_or(default)
redirect_to(session[:return_to] || default)
session.delete(:return_to)
end
def store_location
session[:return_to] = request.url if request.get?
end
end
......@@ -18,10 +18,16 @@
<% end %>/&ensp;
<%= @job.title.truncate_words(5) %>
</div>
<%= link_to apply_job_path(job_id: @job.id) do %>
<% if signed_in? && @user.present? %>
<div class="apply-job">
<strong>Apply Now</strong>
<strong>Applied</strong>
</div>
<% else %>
<%= link_to apply_job_path(job_id: @job.id) do %>
<div class="apply-job">
<strong>Apply Now</strong>
</div>
<% end %>
<% end %>
</div>
</div>
......@@ -68,10 +74,16 @@
</div>
<div class="row under-descrip">
<div class="col-6">
<%= link_to apply_job_path(job_id: @job.id) do %>
<% if signed_in? && @user.present? %>
<div class="btn btn-info btn-lg apply-btn">
<strong>Apply Now</strong>
<strong>Applied</strong>
</div>
<% else %>
<%= link_to apply_job_path(job_id: @job.id) do %>
<div class="btn btn-info btn-lg apply-btn">
<strong>Apply Now</strong>
</div>
<% end %>
<% end %>
</div>
<div class="col-6">
......
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