I was thinking of adding this as a comment but since it's a bit long, I hope it's fine to place this as an answer.
Your first form_for
looks like
form_for [current_recruiter, application, Message.new], remote: true do |f|
I am assuming that current_recruiter
is an ActiveRecord
object so this translates to recruiter_application_path
which conflicts with the defined route. I've made some experiment using the same code in an existing project. In the console, I ran the following
>> app.recruiter_application_messages_path(1)
=> "/recruiter/applications/1/messages"
>> app.recruiter_application_messages_path(1, 2)
=> "/recruiter/applications/1/messages.2"
>> app.recruiter_application_messages_path(1, Application.new)
=> "/recruiter/applications/1/messages"
So my guess is that there's a route conflict here and application
is a new object. It's a lot of ifs but I think that's your current scenario. In order to use the route declared with a namespace, make sure that application
is a persisted object and change the form_for
to
form_for [:recruiter, application, Message.new], remote: true do |f|
For the second form_for
, I think you just forgot to pass the first argument which is the new message object
form_for Message.new, url: recruiter_application_messages_path(application.id)