Commit f2c78d06 by Mai Hoang Thai Ha

add name and email to apply, create apply form

parent 98d6bf79
// Place all the styles related to the Applies controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: https://sass-lang.com/
class AppliesController < ApplicationController
before_action :load_job, only: %i[new confirm create]
def index
end
def create
end
def show
end
def new
# if params[:job_id].present?
# @job = Job.find_by(id: params[:job_id])
# end
end
def confirm
end
private
def load_job
@job = Job.find_by(id: params[:job_id])
end
end
module AppliesHelper
end
- provide(:title, "Apply job")
.container
h1.my-5.text-center
| Apply for
.col
= form_with(url: confirm_path, local: true) do |f|
.mb-3
= f.label :name, 'Full name', class: 'form-label'
= f.text_field :name, class: 'form-control'
.mb-3
= f.label :email, class: 'form-label'
= f.email_field :email, class: 'form-control'
span.mb-3.d-block.align-center
= f.file_field :cv
= f.submit "Submit", class: "btn btn-primary"
- provide(:title, "Apply job")
.container
h1.my-5.text-center
| Apply for
= @job.title
.col
= form_with(url: confirm_path, local: true) do |f|
.mb-3
= f.label :name, 'Full name', class: 'form-label'
= f.text_field :name, class: 'form-control'
.mb-3
= f.label :email, class: 'form-label'
= f.email_field :email, class: 'form-control'
span.mb-3.d-block.align-center
= f.file_field :cv
= f.submit "Submit", class: "btn btn-primary"
......@@ -2,7 +2,7 @@
.job-apply.d-flex.align-items-center.justify-content-between
h2.align-items-start
= @job.title
= link_to 'Apply for this job', '#', class: 'btn btn-primary'
= link_to 'Apply for this job', apply_path(job_id: Job.find_by(title: @job.title).id), class: 'btn btn-primary'
p.text-secondary
= @job.company.name
.row.bg-light
......@@ -65,5 +65,5 @@
li.text-secondary
= info
.job-apply.d-flex.align-items-center.justify-content-between
= link_to 'Apply for this job', '#', class: 'btn btn-primary'
= link_to 'Apply for this job', apply_path(job_id: Job.find_by(title: @job.title).id), class: 'btn btn-primary'
= link_to 'Favorite', '#', class: 'btn btn-primary'
......@@ -9,4 +9,8 @@ Rails.application.routes.draw do
end
resources :jobs, only: %i[index show]
get '/apply', to: 'applies#new'
post '/confirm', to: 'applies#confirm'
post '/done', to: 'applies#done'
end
class AddNameAndEmailToApplyJobs < ActiveRecord::Migration[6.1]
def change
add_column :apply_jobs, :user_name, :string
add_column :apply_jobs, :email, :string
end
end
......@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2021_07_22_080023) do
ActiveRecord::Schema.define(version: 2021_07_29_140527) do
create_table "active_storage_attachments", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.string "name", null: false
......@@ -45,6 +45,8 @@ ActiveRecord::Schema.define(version: 2021_07_22_080023) do
t.bigint "user_id", null: false
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.string "user_name"
t.string "email"
t.index ["job_id"], name: "index_apply_jobs_on_job_id"
t.index ["user_id"], name: "index_apply_jobs_on_user_id"
end
......
require "test_helper"
class AppliesControllerTest < ActionDispatch::IntegrationTest
# 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