I’m trying to make a partial view that has a dropdown to select the week, and when the submit button is pressed, reopen the same page with new data. Here is the code I’m having problems with:
= form_tag(:controller => "/payroll_issues", :action=> "index") do
When the button is clicked, it brings you to the correct url, but the page doesn’t load, saying “No data received, Unable to load the webpage because the server sent no data.”
The thing is, when I run the code as
= form_tag(:controller => "/payroll_issues", :action=> "change_week") do
where change_week just redirects to index, everything works great. Is there something I’m missing with the index?
The form tag helper creates a form tag with
method = 'post', the route for your index action is probably setup to only accept a'get'request.To check, you can run
rake routesIf you really wanted to, you could add a route to accept post requests with your index action like so:
However, you’d be much better off with the second technique in your question, create a separate action and redirect.