Quick Tip: Routes for a Non-Resourceful Rails Controller

Let’s say you have a few routes that are all related, but don’t really map to the usual resources. For example, a login/logout controller named SessionsController  doesn’t really fit the usual resourceful route model. One could use the usual routes HTTP verb syntax like this

However, there’s a nifty little helper that’s not in the routing guide but is in the API docs called controller which feels a bit cleaner.

After running  rake routes  or  rails routes to see what routes we’ve got, we’ll see three routes.

If there’s an even better way, let me know in the comments!


No Comments

A name is required.
An email is required.
Invalid URL

No comments yet