Sha256: ae4436c67eaba3ea3b009a14fe3e55e99be7b04286aec9edb35d1658e5f7359a

Contents?: true

Size: 1.16 KB

Versions: 6

Compression:

Stored size: 1.16 KB

Contents

module Recruiter
  module Users
    class JobsController < UserController
      before_action :set_job, only: [:show, :edit, :update, :destroy]

      def index
        @jobs = scope.page(page).per(per_page)
        respond_with(@jobs)
      end

      def show
        respond_with(@job)
      end

      def edit
        respond_with(@job)
      end

      def new
        # TODO: This fixes issue #10. Not a beautiful think to do here
        flash.delete(:alert)
        @job = scope.new
        respond_with(@job)
      end

      def create
        @job = scope.build(job_params)
        crud_flash @job.save
        respond_with(@job)
      end

      def update
        crud_flash @job.update(job_params)
        respond_with(@job)
      end

      def destroy
        crud_flash @job.destroy
        respond_with(@job)
      end

      private

      def scope
        current_user.jobs
      end

      def set_job
        @job = scope.find(params[:id])
      end

      def job_params
        params.require(:job).permit(
          :title, :description, :how_to_apply, :city_id, :state_id, tag_ids: []
        ).to_hash.reverse_merge(tag_ids: [])
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
recruiter-0.0.7 app/controllers/recruiter/users/jobs_controller.rb
recruiter-0.0.6 app/controllers/recruiter/users/jobs_controller.rb
recruiter-0.0.5 app/controllers/recruiter/users/jobs_controller.rb
recruiter-0.0.4 app/controllers/recruiter/users/jobs_controller.rb
recruiter-0.0.3 app/controllers/recruiter/users/jobs_controller.rb
recruiter-0.0.2 app/controllers/recruiter/users/jobs_controller.rb