Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do we identify parameters in a dynamic URL?
    primarykey
    data
    text
    <p>We are building a Rails CMS where a blog or news listing can appear anywhere in the site tree. This means that any page knows their type based on a database field - eg: a page knows that it is of type newslisting so once that URL is called for that page we need it to be processed by the newslistingcontroller. The subpages of the newslisting page are news stories - each with a date and category.</p> <p>The URL to the newslisting might be </p> <pre><code>/dogs/snoopy-news/ </code></pre> <p>and a news story might be </p> <pre><code>/dogs/snoopy-news/snoopy-is-great/ </code></pre> <p>The complexity for us is with URLs that have additional parameters in for listing date ranges of news stories or category listings eg:</p> <p>Listing all november news stories</p> <pre><code>/dogs/snoopy-news/2010/11/ </code></pre> <p>Or listing all stories which have food as their category:</p> <pre><code>/dogs/snoopy-news/category/food/ </code></pre> <p>Since that newslisting page could be at any level in the site hierarchy how would we approach identifying that 2010 is a parameter or that category is a parameter?</p> <p>(We will store all URLs in the database for each page so we can lookup first to see if a page exists for a URL)</p> <p>EDIT: This post gives a possible solution: <a href="https://stackoverflow.com/questions/776268/dynamic-cms-like-routes-in-ruby-on-rails">Dynamic CMS like routes in ruby on rails</a> which we will try out and report back on. On save of a page in the CMS we would add routes to the routing table at that point for not only the page itself but for also possible parameters:</p> <pre><code>/dogs/snoopy-news/{year}/{month}/ </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload