One problem is that you do not indicate whether a route is defined in the collection or member. Which one is the right route?
programs/:id/add_file programs/add_file
You should build your routes as follows:
resources :programs do post 'add_file', :on => :member end
or
resources :programs do member do post 'add_file' end end
The above messages will be sent to programs/:id/add_file and sent to ProgramsController.add_file with params[:id] as the program identifier.
If you want this in a collection, you can do:
resources :programs do post 'add_file', :on => :collection end
or
resources :programs do collection do post 'add_file' end end
This will take the post requests to programs/add_file and send them to ProgramsController.add_file , but there will be no params[:id] .
In general, you should always indicate whether the routes are in the collection or member, and you must indicate which verb the route should take (i.e. use "get" or "post", etc. instead of "match").
Try the above and see if this solves your problem, if you do not tell me, and I will look again.
source share