Commit 1d758282 by Hoang Nam Nguyen

'create history_page'

parent 44f4d89b
...@@ -10,5 +10,7 @@ class JobController < ApplicationController ...@@ -10,5 +10,7 @@ class JobController < ApplicationController
def detail def detail
@job = Job.find(params[:id]) @job = Job.find(params[:id])
@history = History.find_or_create_by(job_id: @job.id,user_id: current_user.id)
@history.touch(:updated_at)
end end
end end
...@@ -15,7 +15,7 @@ class TopPagesController < ApplicationController ...@@ -15,7 +15,7 @@ class TopPagesController < ApplicationController
@cities = City.limit(ENV["Number_top_page"]) @cities = City.limit(ENV["Number_top_page"])
end end
def show def history
end end
def index def index
......
class History < ApplicationRecord
belongs_to :user
has_many :jobs
end
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
<% end %> <% end %>
<li> <li>
<%= link_to '#',class: 'btn btn-info distance mt-1 no-gutters' do %> <%= link_to history_path,class: 'btn btn-info distance mt-1 no-gutters' do %>
<i class="fa fa-history"></i> History <i class="fa fa-history"></i> History
<% end %> <% end %>
</li> </li>
......
<%= provide(:title,"History")%>
<h1 class="text-danger text-center mt-5">History</h1>
require 'sidekiq/web' require 'sidekiq/web'
Rails.application.routes.draw do Rails.application.routes.draw do
get 'password_resets/new' get 'password_resets/new'
get 'password_resets/edit' get 'password_resets/edit'
get 'sessions/new' get 'sessions/new'
get 'users/new' get 'users/new'
get '/cities',to: 'top_pages#cities' get '/cities',to: 'top_pages#cities'
get '/industries',to: 'top_pages#industries' get '/industries',to: 'top_pages#industries'
get '/history',to: 'top_pages#history'
get 'top_pages/cities' get 'top_pages/cities'
get 'top_pages/industries' get 'top_pages/industries'
get 'top_pages/top_page' get 'top_pages/top_page'
......
class CreateHistories < ActiveRecord::Migration[5.1]
def change
create_table :histories do |t|
t.integer :job_id
t.timestamps
end
end
end
class AddUserIdToHistory < ActiveRecord::Migration[5.1]
def change
add_column :histories, :user_id, :integer
end
end
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20171004020516) do ActiveRecord::Schema.define(version: 20171005062654) do
create_table "add_cv_to_users", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t| create_table "add_cv_to_users", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.string "cv" t.string "cv"
...@@ -43,6 +43,13 @@ ActiveRecord::Schema.define(version: 20171004020516) do ...@@ -43,6 +43,13 @@ ActiveRecord::Schema.define(version: 20171004020516) do
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
end end
create_table "histories", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.integer "job_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "user_id"
end
create_table "industries", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t| create_table "industries", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.string "industry_name" t.string "industry_name"
t.datetime "created_at", null: false t.datetime "created_at", null: false
......
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
job_id: 1
two:
job_id: 1
require 'test_helper'
class HistoryTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# 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