Confused with routes in Wheels 2.0 beta

99 views
Skip to first unread message

Seona Bellamy

unread,
Jun 6, 2017, 3:16:17 AM6/6/17
to cfwh...@googlegroups.com
Hi folks,

I've been having a poke around with the 2.0 beta, since I have a personal project in mind that looked like a good test-bed for the new framework. Routes, however, are defeating me. I've read through all of the documentation and I thought I had my head around it, but it just won't play nicely.

I have the following login form on my homepage:

#startFormTag(route="login")#
    #textFieldTag(name="email", value=params.email, label="Email")#
    #passwordFieldTag(name="password", label="Password")#
    #submitTag(value="Login", class="btn btn-primary")#
#endFormTag()#


I have the following line in routes.cfm:

.get(name="login", to="sessions##create")

When I submit the login form, however, I get the following error:

Wheels.RouteNotFound

Could not find a route that matched this request.

Suggested action

Make sure there is a route configured in your config/routes.cfm file that matches the login request.


Now, correct me if I'm wrong, but I thought I did? Or am I missing something fundamental in my understanding of how the new routing system works? (I've been awake since 3am, so that's entirely possible...)

Cheers,

photo
Seona Bellamy
Web Developer

Per Djurner

unread,
Jun 6, 2017, 3:34:54 AM6/6/17
to cfwh...@googlegroups.com
Replace .get with .post.
--
You received this message because you are subscribed to the Google Groups "CFWheels" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cfwheels+u...@googlegroups.com.
To post to this group, send email to cfwh...@googlegroups.com.
Visit this group at https://groups.google.com/group/cfwheels.
For more options, visit https://groups.google.com/d/optout.

Seona Bellamy

unread,
Jun 6, 2017, 3:51:58 AM6/6/17
to cfwh...@googlegroups.com
Oh, is this because it's handling a form submission?

Makes sense, but isn't something I'd figured out from the docs. (Which isn't to say it isn't in there somewhere - see earlier comment about having been awake for about 15 hours!)

Route works now. Happy days! Thanks. :D

Cheers,

photo
Seona Bellamy
Web Developer
Replace .get with .post.
To unsubscribe from this group and stop receiving emails from it, send an email to cfwheels+unsubscribe@googlegroups.com.

To post to this group, send email to cfwh...@googlegroups.com.
Visit this group at https://groups.google.com/group/cfwheels.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "CFWheels" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cfwheels+unsubscribe@googlegroups.com.

To post to this group, send email to cfwh...@googlegroups.com.
Visit this group at https://groups.google.com/group/cfwheels.
For more options, visit https://groups.google.com/d/optout.



--

Per Djurner

unread,
Jun 6, 2017, 4:13:04 AM6/6/17
to cfwh...@googlegroups.com
Yes, that's why.

I'll add an issue on GitHub to improve the docs if needed.

Thanks :)
Replace .get with .post.
To unsubscribe from this group and stop receiving emails from it, send an email to cfwheels+u...@googlegroups.com.

To post to this group, send email to cfwh...@googlegroups.com.
Visit this group at https://groups.google.com/group/cfwheels.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "CFWheels" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cfwheels+u...@googlegroups.com.

To post to this group, send email to cfwh...@googlegroups.com.
Visit this group at https://groups.google.com/group/cfwheels.
For more options, visit https://groups.google.com/d/optout.
--


photo
Seona Bellamy
Web Developer

--
You received this message because you are subscribed to the Google Groups "CFWheels" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cfwheels+u...@googlegroups.com.

Seona Bellamy

unread,
Jun 6, 2017, 4:36:45 AM6/6/17
to cfwh...@googlegroups.com
Looks like I'm not out of the woods yet.

I have a redirection in the Users controller - if the user is successfully logged in, redirect them to their profile page.

I'm using .resources("users") in my routes.cfm as recommended. I look in the "View Routes" link on the homepage and I see that it's created a bunch of different routes, most of which have the name "user". I'm assuming that this means that I can just pass "user" as the route and it will go to the appropriate controller/action based on what the URL pattern is. Is that correct?

Assuming that's correct, I have the redirection set up as:

redirectTo(route="user", key=1, message="Signed in successfully.", messageType="success");

I've hard-coded the key in for now just to remove one possible point of failure - I know that there is a record with an ID of 1 in the users table. Once I have it working that will be replaced by the logged-in user's ID.

Anyway, when I submit the login form it successfully logs in and then redirects to http://127.0.0.1:60000/users/1. This matches a pattern in the routes list that should use the "show" action. However I'm getting the following error:

Wheels.ViewNotFound

Could not find the view page for the 1 action in the Users controller.

Suggested action

Create a file named 1.cfm in the views/users directory (create the directory as well if it doesn't already exist).


Any idea what's gone wrong here? Why isn't it matching the pattern to the existing route?


Cheers,

photo
Seona Bellamy
Web Developer
Replace .get with .post.
To unsubscribe from this group and stop receiving emails from it, send an email to cfwheels+unsubscribe@googlegroups.com.

To post to this group, send email to cfwh...@googlegroups.com.
Visit this group at https://groups.google.com/group/cfwheels.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "CFWheels" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cfwheels+unsubscribe@googlegroups.com.

To post to this group, send email to cfwh...@googlegroups.com.
Visit this group at https://groups.google.com/group/cfwheels.
For more options, visit https://groups.google.com/d/optout.
--


photo
Seona Bellamy
Web Developer

--
You received this message because you are subscribed to the Google Groups "CFWheels" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cfwheels+unsubscribe@googlegroups.com.

To post to this group, send email to cfwh...@googlegroups.com.
Visit this group at https://groups.google.com/group/cfwheels.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "CFWheels" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cfwheels+unsubscribe@googlegroups.com.

To post to this group, send email to cfwh...@googlegroups.com.
Visit this group at https://groups.google.com/group/cfwheels.
For more options, visit https://groups.google.com/d/optout.

Tom King

unread,
Jun 6, 2017, 5:07:52 AM6/6/17
to CFWheels

You're right, that should match;
Just to check, a) you've reloaded the app since adding new routes, and b) there isn't a route above which might be taking precedence? i.e, wildcard()

T
Replace .get with .post.
To unsubscribe from this group and stop receiving emails from it, send an email to cfwheels+u...@googlegroups.com.

To post to this group, send email to cfwh...@googlegroups.com.
Visit this group at https://groups.google.com/group/cfwheels.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "CFWheels" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cfwheels+u...@googlegroups.com.

To post to this group, send email to cfwh...@googlegroups.com.
Visit this group at https://groups.google.com/group/cfwheels.
For more options, visit https://groups.google.com/d/optout.
--


photo
Seona Bellamy
Web Developer

--
You received this message because you are subscribed to the Google Groups "CFWheels" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cfwheels+u...@googlegroups.com.

To post to this group, send email to cfwh...@googlegroups.com.
Visit this group at https://groups.google.com/group/cfwheels.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "CFWheels" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cfwheels+u...@googlegroups.com.

To post to this group, send email to cfwh...@googlegroups.com.
Visit this group at https://groups.google.com/group/cfwheels.
For more options, visit https://groups.google.com/d/optout.

Seona Bellamy

unread,
Jun 6, 2017, 5:50:31 AM6/6/17
to cfwh...@googlegroups.com
Aha! Turns out it was the wildcard() placement. It was at the top of the mapper() block that was auto-generated, so I assumed that was where it was supposed to be. I've now moved it to the bottom and my route works as expected.

Yay for learning new things! Thank you. :D


Cheers,

photo
Seona Bellamy
Web Developer
To unsubscribe from this group and stop receiving emails from it, send an email to cfwheels+unsubscribe@googlegroups.com.

To post to this group, send email to cfwh...@googlegroups.com.
Visit this group at https://groups.google.com/group/cfwheels.
For more options, visit https://groups.google.com/d/optout.

Chris Peters

unread,
Jun 6, 2017, 9:06:44 AM6/6/17
to cfwh...@googlegroups.com
You'll likely want to set up a singular resource called something like profile:
.resource("profile")

That tends to be a better match for entities that are tied to the user's session because it doesn't expose primary keys in the URL.

Chris Peters
Web Developer
Liquifusion Studios

chris....@liquifusion.com
Skype: liquifusion.support
www.liquifusion.com

Seona Bellamy

unread,
Jun 6, 2017, 9:31:26 PM6/6/17
to cfwh...@googlegroups.com
So would that require a separate "Profiles" controller?


photo
Seona Bellamy
Web Developer

Chris Peters

unread,
Jun 7, 2017, 9:00:45 AM6/7/17
to cfwh...@googlegroups.com
Yes, it would. I typically find that to be a good course to take because you're loading the user based on a session ID rather than a parameter passed in the URL.

Seona Bellamy

unread,
Jun 7, 2017, 8:50:40 PM6/7/17
to cfwh...@googlegroups.com
Okay, definitely see the logic in that. And it turned out to be surprisingly easy to get working, too. Go Wheels! :D

Thanks for the help and suggestions.


Cheers,

photo
Seona Bellamy
Web Developer

Chris Peters

unread,
Jun 8, 2017, 9:06:49 AM6/8/17
to cfwh...@googlegroups.com
You're welcome. 👍
Reply all
Reply to author
Forward
0 new messages