Using URL path in REST app as ID

I'm a Rails newbie, so please bear with me. I want to use the URL as the
ID for a RESTful resource, but using the path after the controller. The
remaining portion of the URL would be the ID, rather than an integer.

So rather than just:

I want to use:

where foo, foo/bar and foo/bar/baz are all Widgets, not nested resources.

In the controller I'd like to do something like

@widget = Widget.find(params[:path])

where path is a string column defined as a primary key (or unique)
containing strings like 'foo', 'foo/bar' and 'foo/bar/baz'

Is this possible?