Ajax 404 not found

hi everyone, i'm trying to make a post request with ajax in a js function.

but here i am , 404 error , i really don't get why , help :3

Attachments: http://www.ruby-forum.com/attachment/10551/bug.png

hi everyone, i'm trying to make a post request with ajax in a js function.

but here i am , 404 error , i really don't get why , help :3

Attachments: http://www.ruby-forum.com/attachment/10551/bug.png

Please in future copy/paste the relevant code rather than using a screenshot. It is much easier for us to read, especially on mobile devices.

Are you running in production mode, if so have you restarted the server since any changes made?

What is in the log file for the post?

Copy/paste routes.rb here please.

Colin

Look in the logs, inspect your actual request, compare it to your routes. (In particular, you may have defined a route that only responds to GET, and now you're tying to POST to it.)

Colin Law wrote in post #1169453:

Please in future copy/paste the relevant code rather than using a screenshot. It is much easier for us to read, especially on mobile devices.

Are you running in production mode, if so have you restarted the server since any changes made?

What is in the log file for the post?

Copy/paste routes.rb here please.

Colin

yes i'm in production mode , i run two command on my server before my tests

-rake assets:precompile -service apache2 reload

here is my log file for the post

Started POST "/admin/archiveMail" for 172.16.20.28 at 2015-03-02 10:59:07 +0100

AbstractController::ActionNotFound (The action 'archiveMail' could not be found for AdminController):   actionpack (3.2.14) lib/abstract_controller/base.rb:116:in `process'   actionpack (3.2.14) lib/abstract_controller/rendering.rb:45:in `process'   actionpack (3.2.14) lib/action_controller/metal.rb:203:in `dispatch'   actionpack (3.2.14) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'   actionpack (3.2.14) lib/action_controller/metal.rb:246:in `block in action'   actionpack (3.2.14) lib/action_dispatch/routing/route_set.rb:73:in `call'   actionpack (3.2.14) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'   actionpack (3.2.14) lib/action_dispatch/routing/route_set.rb:36:in `call'   journey (1.0.4) lib/journey/router.rb:68:in `block in call'   journey (1.0.4) lib/journey/router.rb:56:in `each'   journey (1.0.4) lib/journey/router.rb:56:in `call'   actionpack (3.2.14) lib/action_dispatch/routing/route_set.rb:608:in `call'   pdfkit (0.5.4) lib/pdfkit/middleware.rb:16:in `call'   actionpack (3.2.14) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'   rack (1.4.5) lib/rack/etag.rb:23:in `call'   rack (1.4.5) lib/rack/conditionalget.rb:35:in `call'   actionpack (3.2.14) lib/action_dispatch/middleware/head.rb:14:in `call'   actionpack (3.2.14) lib/action_dispatch/middleware/params_parser.rb:21:in `call'   actionpack (3.2.14) lib/action_dispatch/middleware/flash.rb:242:in `call'   rack (1.4.5) lib/rack/session/abstract/id.rb:210:in `context'   rack (1.4.5) lib/rack/session/abstract/id.rb:205:in `call'   actionpack (3.2.14) lib/action_dispatch/middleware/cookies.rb:341:in `call'   activerecord (3.2.14) lib/active_record/query_cache.rb:64:in `call'   activerecord (3.2.14) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'   actionpack (3.2.14) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'   activesupport (3.2.14) lib/active_support/callbacks.rb:405:in `_run__4592187661148133351__call__300096097883725408__callbacks'   activesupport (3.2.14) lib/active_support/callbacks.rb:405:in `__run_callback'   activesupport (3.2.14) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'   activesupport (3.2.14) lib/active_support/callbacks.rb:81:in `run_callbacks'   actionpack (3.2.14) lib/action_dispatch/middleware/callbacks.rb:27:in `call'   rack (1.4.5) lib/rack/sendfile.rb:102:in `call'   actionpack (3.2.14) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'   actionpack (3.2.14) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'   actionpack (3.2.14) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'   railties (3.2.14) lib/rails/rack/logger.rb:32:in `call_app'   railties (3.2.14) lib/rails/rack/logger.rb:16:in `block in call'   activesupport (3.2.14) lib/active_support/tagged_logging.rb:22:in `tagged'   railties (3.2.14) lib/rails/rack/logger.rb:16:in `call'   actionpack (3.2.14) lib/action_dispatch/middleware/request_id.rb:22:in `call'   rack (1.4.5) lib/rack/methodoverride.rb:21:in `call'   rack (1.4.5) lib/rack/runtime.rb:17:in `call'   activesupport (3.2.14) lib/active_support/cache/strategy/local_cache.rb:72:in `call'   rack (1.4.5) lib/rack/lock.rb:15:in `call'   actionpack (3.2.14) lib/action_dispatch/middleware/static.rb:63:in `call'   rack-cache (1.2) lib/rack/cache/context.rb:136:in `forward'   rack-cache (1.2) lib/rack/cache/context.rb:143:in `pass'   rack-cache (1.2) lib/rack/cache/context.rb:155:in `invalidate'   rack-cache (1.2) lib/rack/cache/context.rb:71:in `call!'   rack-cache (1.2) lib/rack/cache/context.rb:51:in `call'   railties (3.2.14) lib/rails/engine.rb:484:in `call'   railties (3.2.14) lib/rails/application.rb:231:in `call'   railties (3.2.14) lib/rails/railtie/configurable.rb:30:in `method_missing'   passenger (4.0.18) lib/phusion_passenger/rack/thread_handler_extension.rb:77:in `process_request'   passenger (4.0.18) lib/phusion_passenger/request_handler/thread_handler.rb:140:in `accept_and_process_next_request'   passenger (4.0.18) lib/phusion_passenger/request_handler/thread_handler.rb:108:in `main_loop'   passenger (4.0.18) lib/phusion_passenger/request_handler.rb:441:in `block (3 levels) in start_threads'

and here is my routes.rb

WebGTI::Application.routes.draw do

root :to =>'login#index' match ':controller(/:action(/:id(.format)))' end

thank you for your help !

Does that restart your rails server? I don't know.

Does it work in development mode on your development system?

Colin

Does that restart your rails server? I don't know.

Does it work in development mode on your development system?

Colin

it does restart my rails server , but et doesn't work in development mode on y development system.

and here is my routes.rb

WebGTI::Application.routes.draw do

root :to =>'login#index' match ':controller(/:action(/:id(.:format)))' end

I don't know, but I wonder whether the camelcase is causing a problem. I always try to stick to the rails conventions for such things. I suggest trying changing the name to archivemail in the action and in the url to see if it helps.

Colin

i changed 2 thinks , i declare my function on the top of my admin_controller.rb file and change the camelcase to archivemail. i don't know wath solve the problem , but it work !

thank you really much for your help !!

Tanguy

i changed 2 thinks , i declare my function on the top of my admin_controller.rb file and change the camelcase to archivemail. i don't know wath solve the problem , but it work !

Well you should find out which for future reference (it could be both of course). Did you move it from after a private declaration? Actions need to be in public section.

thank you really much for your help !!

Glad to be of help

Colin

Colin Law wrote in post #1169465:   Did you move it

from after a private declaration? Actions need to be in public section.

after check , it was in private declaration , i'm learning ruby and didn't know private declaration was for all function declare after "private" key word.

Again think for you help , and sorry for my bad english ...

Colin Law wrote in post #1169465:   Did you move it

from after a private declaration? Actions need to be in public section.

after check , it was in private declaration , i'm learning ruby and didn't know private declaration was for all function declare after "private" key word.

OK, that explains it. I should have thought of that earlier. I still suggest not using action names with capital letters though.

Again think for you help , and sorry for my bad english ...

It is not bad at all.

Another issue you might like to think about is that you are using a very old version of rails. You should at least update to 3.2.21 as you are missing a number of security fixes. Also version 3.2 will go out of support within a few months I think and will not get even security fixes any more. No publicly accessible site should be using 3.2 after that.

Also it is, I think, a bad idea to keep the default route match ':controller(/:action(/:id(.:format)))' as that allows get and post access to any action in any controller. You should explicitly define the routes you actually want and whether they are GET, POST etc.

Colin