A brief breakdown of this route:
match “/pick_gender(/:gender)”, to: “my_controller#pick_gender”, via: “GET”, as: :pick_gender
1. match
will match a GET (i.e. it will be the same as using get
) if we use via: "GET"
You can simplify it to:
get "/pick_gender(/:gender)", to: "my_controller#pick_gender", as: :pick_gender
or if you want to use the => syntax to:
get "/pick_gender(/:gender)" => "my_controller#pick_gender", as: :pick_gender
2. to: matches this resource (the GET on the URL) to the
pick_gender method of the
my_controller controller
3. finally, using as: will create a named route, i.e. you get a
pick_gender_path and
pick_gender_url for free as named helpers
More on named routes here:
http://guides.rubyonrails.org/routing.html#naming-routes
More on Rails routes generally here:
http://guides.rubyonrails.org/routing.html
More on match vs
get` here:
http://stackoverflow.com/questions/6988866/ruby-on-rails-routes-difference-between-get-and-match