I need to create this url:
www.example.com/directory/[state]-financial-planners
Where [state] will be different depending on which link users click…e.g: /directory/california-financial-planners etc. I would like to create those urls with function like state_directory_path("california"), and my receiving controller should have a variable params[:state].
Thanks
You need a route with a Dynamic Segment:
This dynmic segment is the
:statepart of the route, this will setparam[:state]in the request. You will need to specify'controller_name#action_method'with the controller and action that will handle the request