goodieboy
2008-Jan-13 22:04 UTC
CMS - how to associate "pages" with controllers and routes
Hi, 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 simply: render :text=>page.body No problem. 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? My worries: 1. is there a better way? 2. what about routes? Can I do this without creating my own url parsing code? 3. time 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. Thanks, Matt --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---