I have job model. In action show I have fontawesome icon with method: delete. When I edit job all is ok but when I click on icon with method delete nothing happens :( On the localhost its working but on production only action edit :/ When I click on the trash icon it looks like the page is only refreshing.
show.html.erb
<% if job_author(@job) %>
<%= link_to edit_job_path(@job) do %>
<i class="far fa-edit" style="font-size: 30px; margin-top: 15px"></i>
<%= link_to @job, method: :delete do %>
<i class="fas fa-trash-alt" style="font-size: 30px; margin-top: 15px"></i>
<% else %>
<% end %>
<% end %>
<% end %>
jobs_controller.rb
class JobsController < ApplicationController
before_action :set_job, only: [:show, :edit, :update, :destroy]
before_action :authenticate_user!, except: [:index, :show]
def set_job
@job = Job.find(params[:id])
end
def destroy
@job = Job.find(params[:id])
@job.destroy
respond_to do |format|
format.html { redirect_to root_path }
format.json { head :no_content }
end
end
def index
@jobs = Job.all
if params[:search]
@jobs = Job.search(params[:search]).order("created_at DESC")
else
@jobs = Job.all.order("created_at DESC")
end
if(params.has_key?(:job_type))
@jobs = Job.where(job_type: params[:job_type]).order("created_at desc")
end
if(params.has_key?(:job_category))
@jobs = Job.where(job_category: params[:job_category]).order("created_at desc")
end
end
def show
@job = Job.find(params[:id])
end
def new
@job = current_user.jobs.build
@job = Job.new
end
def edit
if current_user.id == @job.user.id
@job = Job.find(params[:id])
else
flash[:danger] = "You do not have authorization to edit this post"
redirect_to root_path
end
end
def create
@job = current_user.jobs.build(job_params)
job_type = params[:job_type]
job_salary = params[:salary]
job_title = params[:title]
job_category = params[:job_category]
job_technologies = params[:technologies]
job_additional_technologies = params[:additional_technologies]
job_data = params[:data]
job_godzina = params[:godzina]
respond_to do |format|
if @job.save
format.html { redirect_to 'https://commerce.coinbase.com/checkout/9d7f7bae-db41-4128-b0cd-b2c73b5585d8' }
else
format.html { render :new }
format.json { render json: @job.errors, status: :unprocessable_entity }
end
end
end
def update
@job = Job.find(params[:id])
respond_to do |format|
if @job.update(job_params)
format.html { redirect_to @job }
format.json { render :show, status: :ok, location: @job }
else
format.html { render :edit }
format.json { render json: @job.errors, status: :unprocessable_entity }
end
end
end
def job_params
params.require(:job).permit(:title, :description, :requirements, :url, :job_type, :location, :job_author, :remote, :apply_url, :avatar, :salary, :multisport_card, :medical_care, :cold_drinks, :parking, :job_category, :technologies, :additional_technologies, :data, :godzina)
end
end