Routing problem to access the driver

2

Hi, I'm a rookie in Rails and I have trouble accessing a controller method from a view.

I created a form in the view

  <form id="form-cargaMasiva" action="/redmine/issues/load" method="get">
...
...
...
</form>

my goal is that when I submit using javascript I take the controller method that I called load, my controller is called issues_controller, as I understand to redirect you to the load method you have to put in the file routes.rb

get 'issues/load', :to => 'issues#load'

But there's no way it works, it gives me a 404

    
asked by Francisco Pagan 10.11.2016 в 12:22
source

1 answer

0
  • In your action you point to /redmine/issues/load , but in your routes you have defined issues/load . For it to work, both routes must be the same.
  • If you are learning rails, try rails conventions. You are using a verb GET for a form which, although it should work, is wrong. Normally you should use a POST to create elements and a PUT or PATCH to update elements.
  • You are using <form> when what you should do is use form_for or last form_tag .
  • You should put an alias to your get, that is something like get 'issues/load', :to => 'issues#load', as: cualquier_nombre , then then call it as cualquier_nombre_path where you need it.

I do not know if you are learning from a tutorial or what, but if all those things that I detailed in the little code that you showed are for some tutorial that you were following, better change of tutorial.
Greetings

    
answered by 11.11.2016 / 15:41
source