0
Hello,
I have two applications running on Heroku with the same code, only I’m having a little problem with the producing.
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 in the controller Managers::RecruitmentsController, but the correct would be in Managers::ApplicantsController, as already happens in the version dev:
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 down 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
						
what appears when you rotate a rake Routes?
– Thiago Diniz
@Thiagodiniz,appears all routes, but as for the controller in question I will edit in my reply.
– augustoppimenta
You checked if the route is right in html?
– Thiago Diniz
Wow @Thiagodiniz... I didn’t think about it! I refactored the code by transferring the
link_tofor a view to respond to the same controller that in the case was Applicants. Like, the view I was making the request was related to the Recruitments controller, so I transferred the code to the view that responds to the Applicants controller, without losing value to the business. I don’t know if this was the problem but it worked out. PS.: I’m a beginner in the Rails world!– augustoppimenta