I’ve developed a simple CMS. I want to be able to create re-usable
applications. One of them, a simple PayPal shop. In the backend, you
can add “pages”. Very simple, a “code” and the “body”. The “code” is
use as the identifier (about, about/me etc.). I’ve been mapping all
(public) pages to a DefaultController. Th DefaultController looks at
the PATH_INFO string and determines which “page” to get. It then
Now, I have to somehow setup the e-commerce application. I have one
client that wants to call the url “collection” and another that wants
to call it “shop”. My thought was to add a few more fields to the page
models; :handler and :action. Before the DefaultController renders the
page, it would check to see if it had a handler associated with it and
then include it (include MyPageHandler) to bring it into the scope of
a controller. Actually, I did this and it seems to work.
But what happens when the user creates a page with a code of
“collection/item”. On that page I guess you’d set the handler to
ShopHandler and the action to “item”. But how does the
ShopHandler.item method get the id of the product without parsing the
URL (PATH_INFO)? Because this stuff 'aint gonna be found in the
routes. Unless… someone knows of a way?
What about looping through all of my pages in the routes.rb file and
setting them that way?
- is there a better way?
- what about routes? Can I do this without creating my own url
I’m really under the gun to get this thing done, so if anyone has done
anything like this before, I’d be so grateful to get a tip or two.