Replies: 5 comments 11 replies
|
That's what If you want your users controllers under an admin directory/url path, I'd suggest looking at wrapping your If you are after 2 sets of user resource routes.. one for admin, and one for public users.. maybe look at something like: The guides are pretty good at showing you what's available.. though it can be pretty fiddly getting your routes configured exactly how you want. https://guides.cfwheels.org/cfwheels-guides/handling-requests-with-controllers/routing |
|
Bruce, As Adam points out depending on what you want to achieve using a name space may help you out to better organize your routes, but in the example you posted it is good to remember that routes are resolved in the order they are defined. In your example you define your block of routes with the resources definition and then in the following lines you define additional routes that conflict with the default resources routes. The easiest way to resolve your issue would be to reorder your route definition: |
|
I think there is some details I'm not picking up from the docs yet that frustrates me. I've spent quite a bit of time trying to understand routing in CFW. For example, the logout I want to be a button that takes me to sessions.logout. My route for sessions is: What do I specify for the buttonTo? Here's what I have: Yet that button doesn't work everywhere. If I'm on a webroot page it works. But if I go into admin page, it fails with the error: The buttonTo tag is in the header that appears on every page. |
|
It is in a form made by buttonTo but no authentication field. Here is the rendered code snippet: |
|
@cfcoder Bruce, There are multiple questions and topics in this thread so let me try to answer as best I can. First the topic of the HTTP DELETE, PATCH, and PUT verbs. As you have pointed out, modern browsers only handle GET and POST. CFWheels allows you to define all the possible HTTP verbs including DELETE, PATCH, and PUT when defining routes but when you are submitting requests to these routes, the built in URL generation functions will take care of using hidden fields to specify the intent. That is why the generated code you posted above will take a DELETE route and generate a form using a POST method with a hidden field to specify that the intended method is a DELETE. As for route names, controller, and action definitions in functions like linkTo(). Well, it's good to understand the history and backwards compatibility that needed to be maintained when this functionality was extended. At the core you need to define a controller and action. If only an action is defined, the controller is assumed to be the same controller as the current action. So if you are in an Admin controller and you define a linkTo() on a view page and only define an action, then Admin will be assumed for the controller, but if you define both the controller and action then those values will be used in the linkTo(). With the migration to v2.0 and introduction of resource based routing the resource name was introduced as a mechanism to forgo defining the controller and action and instead define the route you wish to use. But as you've pointed out, the route names are only unique when combined with the HTTP method.
As @MvdO79 suggested, I think what you should be defining here should be: |

Uh oh!
There was an error while loading. Please reload this page.
I created routes for /users using the following:
I then look at the routing table and test "/users/adminEdit" with GET and it maps to /users/[key]. I didn't specify a key in the test. If I had it maps to /users/adminEdit/[key]. What is going on?

Routes:
All reactions