I'm creating a new application and I want to setup my urls to that
similar of rails and django. In my previous CB apps, I modified the
standard route to pass multiple variables like so...
addCourse(":handler/:action?/:id?/:subid?")
this worked out, however I'd like a more meaningful route/resource
similar to...
has anyone done something similar to this? I'm not sure if my
"subaction" would be another event handler or just another action
within my handler... Not sure, just throwing some ideas, but at some
points in my app I need to be able to pass multiple variables.
I lean towards nesting routes/actions and each nested action is its
own handler. And if necessary (most of the time it is), your nested
action will used a before filter to load up the parent resource.
For example, lets say your routes was something like:
/:handler/:group_id/:subaction/:member_id
and you could match it to:
/groups/19/show/45
Which in English says, "for Group ID=19, show me the membership for
Member ID=45"
In the above setup, you would have 2 handlers "groups" and
"group_memberships". Your "group_memberships" has an event called
"show". In this controller it has a before filter that does a DB
lookup on "group_id" and places it in your request context so you have
immediate access to it.
Rails bakes in this approach naturally, but it seems to be a good fit
for CB apps too.
I guess this is the time that I admit... I have never actually built a
CB app. But I have built a ton of Rails apps and thats exactly the
approach that I usually employ. When I do build my first CB app I will
try and employ the same pattern. I didnt know about optional actions /
parameters, so this is good to know...