I have to migrate a Rails app from 3.0.6 to 5.0 and am stuck - in the older routes.rb the only route was the ill advised:
match ':controller(/:action(/:id(.:format)))'
The application has no index method but does use an index.html.erb that puts up a form that renders to:
<form accept-charset="UTF-8" action="simple/rslts" controller="simple" method="post">
This executes a rslts method that uses rslts.html.erb and works using parameters passed in from the form.
I move this exact same code to the v5 system and specify the routes as:
Prefix Verb URI Pattern Controller#Action
simple GET /simple(.:format) simple#index
POST /simple(.:format) simple#rslts
root GET / welcome#index"
It runs the index.html.erb and I get this in the rendered form:
<form controller="simple" action="simple/rslts" accept-charset="UTF-8" method="post">
It fails saying it can't find a route for /simple/simple/rslts
I change the code and now render:
<form controller="simple" action="rslts" accept-charset="UTF-8" method="post">
It fails saying it can't find a route for /simple/rslts but as you can see from the routes I listed that does exist.
I have munged this around a dozen ways and read the routing guide with no enlightenment. This is only controllers and views, nothing else. I hope someone can help me.
/simple/simple/rslts
: Your action
attribute is just "simple/rslts" which is relative to the current URL. You'll need to prepend a slash, e.g. action="/simple/rslts"
.simple#rslts
is the controller and action name, not part of the URL (which is on the left and has an optional format specifier). Instead you have defined that POST /simple
should direct to the rslts
action. You'll need to add a route for /simple/rslts
or change the action (again) to post directly to /simple
.post '/simple/rslts' => 'simple#rslts'
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments