Hello,
I have two applications running in Heroku with the same code, but I'm having a problem with the production version.
When trying to make a request, I have the following log:
AbstractController::ActionNotFound (The action 'destroy' could not be found for Managers::RecruitmentsController)
The problem is that it is trying to search the controller Managers::RecruitmentsController
, but the correct one would be in Managers::ApplicantsController
, as it already happens in the dev version:
Started DELETE "/managers/recruitments/1/applicants/7" for 179.156.49.112 at
Processing by Managers::ApplicantsController#destroy as HTML
Well, this request comes from link_to below:
<%= link_to "Outra chance?", "javascript:;", id: "newChance", method: 'delete', btn: true, style: :link, 'data-toggle' => 'modal', 'data-target' => '#modalNewChance', 'data-applicant-id' => applicant.id %>
Javascript:
<script language="javascript">
$("#newChance").on('click', function() {
$("#linkNewChance").attr('href', '/managers/recruitments/<%= @recruitment.id %>/applicants/' + $("#newChance").data('applicant-id'));
});
</script>
My controller:
class Managers::ApplicantsController < Managers::BaseController
...
def destroy
@applicant = Applicant.find(params[:id])
CandidatesMailer.new_chance(@applicant).deliver
CompanyMailer.new_chance_company(@applicant).deliver
@applicant.destroy
flash[:success] = "Aplicação resetada com sucesso. Candidato tem nova chance."
redirect_to managers_recruitment_path(params[:recruitment_id])
end
My routes:
namespace :managers do
get "guide/index"
resource :dashboard, only: :show
resource :profile, only: [:show, :edit, :update]
resource :company, only: [:edit, :update, :destroy] do
resource :payment, only: [:edit, :update]
end
resources :plans, only: [:new, :create], path_names: { new: 'choose' }
resources :recruitments do
member do
patch 'close'
end
resources :applicants do
member do
put 'comment'
patch 'comment'
end
end
end
end