Re: Building a Glossary from a Legacy DB
I had to hack up my routes.rb in ways that you probably wouldnt approve of, but this looks like the perfect opportunity for me to start writing some tests for refactoring.
Sidenote: In order to solve the issue of clean URLs which match my existing links, I have utilized permalinks. In order to generate these I needed to make a column called "permalink" and then I redid my import migration with the following code added to my Terms Model (i thought terms was better read than glossaries)
@attributes['permalink'] = title.downcase.gsub(/\s+/, '-').gsub(/[^a-zA-Z0-9_]+/, '')
instant permalinks for all 4,000+ entries in my table. Of course I had more tweaking to do in my controller: Basically replacing find for find_by_permalink and :id for :permalink
@term = Term.find_by_permalink(params[:permalink])
My views also needed some tweakage
<%= link_to 'Show', :controller => 'terms', :action => 'show', :permalink => term.permalink %>
And there you have it!
Man it is so gratifying to know that I wont have to change any of the links in my existing articles. It's also a huge bonus being able to make my entries now without specifying the damn letter each time. Thanks for your coding and patience Ryan.