I enabled this line in route.rb
match ':controller(/:action(/:id))(.:format)'
The HTML generated by erb
is like this:
<form method="post" action="/client_workouts/find"
accept-charset=“UTF-8”>
In the controller, it looks like this:
def find
puts params[:search_string]
end
When I input some text in the text_field and click Search
, the find
function can print out the value of that text.
This looks magic to me. Because in the route
, the variable name is
id
, but in the controller
, this variable can be used by params
. I
was wondering whether id
is a magic variable that maps to param
.
Does anyone have ideas about this. Thanks!