title: Passing ID into a static route -- match page.url => "pages#show", :id => page.id -- not working
body: <p>I'm trying to create page model with activeadmin, and awesome_nested_set. I've been trying to figure out how to create dynamic routes with the correct trailing slugs (e.g. /page1/page1subpage/a-subpage-of-page1subpage/ etc). I found a post by someone else here with some rails2 code I turned into this inside my routes.rb:</p>
  
  <pre><code>Page.all.each do |page|
    page.url = "/"+page.self_and_ancestors.map{|p| p.slug}.join("/")
    page.save
    match page.url =&gt; "pages#show", :id =&gt; page.id
  end
  </code></pre>
  
  <p>It's just not passing any IDs through. How do I get rails3 to pass the ID into the route?? it's just connecting all the pages to pages#show with no id param.</p>
  
  <p>Also if there's a better way to do this in rails 3 let me know.</p>
  
  <p>EDIT: it looks like rails doesn't like passing :id as a param.. If I change it to :page_id it works..</p>
  
  <pre><code>match page.url, :controller =&gt; 'pages', :action =&gt; 'show', :page_id =&gt; page.id
  </code></pre>
  
  <p>How can I reload the routes or do this within active record though?</p>
  
  <p>Answer (later edit): I ended up making a after_validation method that checks if slug_changed? and for itself and it's ancestors and descendants, re creates a url for itself, saves it, then calls:</p>
  
  <pre><code>MyAppName::Application.reload_routes!
  </code></pre>
  
  <p>And I removed the page.save method in the routes.. that also causes some problems when doing things like rake db:migrate on new DBs.</p>