Commit 2ed9d395 by Thanh Hung Pham

Add applied jobs page

parent f6d43b6b
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
// Place all the styles related to the Jobs controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
class JobsController < ApplicationController
def applied_jobs
@applied_jobs = Apply.where(user_id: current_user.id)
render :applied_jobs
end
end
...@@ -24,6 +24,10 @@ class RegistrationsController < Devise::RegistrationsController ...@@ -24,6 +24,10 @@ class RegistrationsController < Devise::RegistrationsController
end end
end end
def show
render :show
end
protected protected
def after_sign_up_path_for(resource) def after_sign_up_path_for(resource)
......
module JobsHelper
end
<%- provide(:title, 'My Page') -%>
<div class="well">
<h2>My Page</h2>
<div class="form-group">
<label>Email</label><br />
<input type="text" value="<%= current_user.email %>", class="form-control", readonly/>
</div>
<div class="form-group">
<label>Full name</label><br />
<input type="text" value="<%= current_user.fullname %>", class="form-control", readonly/>
</div>
<div class="form-group">
<label>Cv name</label><br />
<input type="text" value="<%= current_user.cv_name %>", class="form-control", readonly/>
</div>
<div class="form-group">
<a class="btn btn-primary" href="<%= edit_user_registration_path %>">Update</a>
<a class="btn btn-primary" href="<%= jobs_applied_jobs_path %>">My Jobs</a>
</div>
</div>
<%- provide(:title, 'Applied jobs') -%>
<div class="well">
<h2>Applied Jobs</h2>
<%- @applied_jobs.each do |apply| -%>
<div class="row">
<%= apply.job.name %>
</div>
<div class="row">
<%= truncate(apply.job.description, length: 250) %>
</div>
<div class="row">
<div class="col-md-4">
<%= apply.job.city.name unless job.city.nil? %>
</div>
<div class="col-md-4">
<%= apply.job.salary %>
</div>
<div class="col-md-4">
<%= apply.job.applied_at %>
</div>
</div>
<%- end -%>
</div>
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<nav> <nav>
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
<%- if user_signed_in? -%> <%- if user_signed_in? -%>
<li> <%= link_to 'My profile', edit_user_registration_path %> </li> <li> <%= link_to 'My profile', registrations_show_path %> </li>
<li> <%= link_to 'Log out', destroy_user_session_path, method: :delete %> </li> <li> <%= link_to 'Log out', destroy_user_session_path, method: :delete %> </li>
<%- else -%> <%- else -%>
<li> <%= link_to 'Login', new_user_session_path %> </li> <li> <%= link_to 'Login', new_user_session_path %> </li>
......
...@@ -4,10 +4,12 @@ Rails.application.routes.draw do ...@@ -4,10 +4,12 @@ Rails.application.routes.draw do
get 'static_pages/home' get 'static_pages/home'
get '/cities', to: 'cities#show' get '/cities', to: 'cities#show'
get '/categories', to: 'categories#show' get '/categories', to: 'categories#show'
get 'jobs/applied_jobs'
resource :cities resource :cities
devise_scope :user do devise_scope :user do
post '/confirmations/update_confirm', to: 'confirmations#update_confirm' post '/confirmations/update_confirm', to: 'confirmations#update_confirm'
get '/registrations/show', to: 'registrations#show'
end end
devise_for :users, controllers: { registrations: 'registrations', devise_for :users, controllers: { registrations: 'registrations',
confirmations: 'confirmations' } confirmations: 'confirmations' }
......
require 'test_helper'
class JobsControllerTest < ActionDispatch::IntegrationTest
test "should get applied_jobs" do
get jobs_applied_jobs_url
assert_response :success
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