My aim is simply to display two optional URL parameters on an index page.
0.0.0.0:3000/comparison --> show: empty comparison index page
0.0.0.0:3000/comparison/3 --> show:
3
0.0.0.0:3000/comparison/3/4 --> show:
3
4
I created a controller + view for "comparison"
rails generate controller comparison
and I added
match ':comparison/:index(/:a(/:b))'
to the routes.rb and added an index.html.erb displaying both parameters
<%= @a %>
<%= @b %>
my controller looks like this, simply forwarding the parameters to the view
class ComparisonController < ApplicationController
def index
@a = params[:a]
@b = params[:a]
end
end
With this I am getting a routing error, e.g.
Routing Error
No route matches [GET] "/comparison/3/4"
How do I get the routing right?