AbstractController :: ActionNotFound for a destroy action

0

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

Here are the Routes related to the above controllers.

    
asked by anonymous 28.06.2014 / 17:30

1 answer

1

the end-point that is called in the code snippet

<script language="javascript">
  $("#newChance").on('click', function() {
  $("#linkNewChance").attr('href', '/managers/recruitments/<%=  @recruitment.id %>/applicants/' + $("#newChance").data('applicant-id'));
  });
 </script>

It takes to the controller Managers::RecruitmentsController same ... Rails is doing right, as can be observed in line 26 of the output of the routes you posted

link

Is there no redirect occurring before the Rails router processes its URL?

    
01.07.2014 / 00:15