Other Notable Files
-generated file provides an application-wide (that is, across all controllers), consistent look-and-feel, which includes things such as the header and footer. However, you can also have controller-specific layouts, so I renamed this file to wiki.rhtml
to make it applicable only to your WikiController. This wiki.rhtml
file also links to the cascading style sheet (CSS) file, public/stylesheets/wiki.css
, which you can in turn use to control the aesthetics of your application such as the colors, fonts, and so on.
The one other pre-generated file, which I have tweaked slightly, is config/routes.rb. By modifying one of the mappings and deleting the generated public/index.html file, you can access the index page without the trailing URI (that is, /wiki/):
map.connect '', :controller => "wiki"
In other words, a URL of http://localhost:3000/ is treated the same as http://localhost:3000/wiki/.
I also added the following line to the config/routes.rb file to allow you to use clean REST (Representational State Transfer)-like web services URLs:
map.connect 'wiki/:action/:f', :controller => "wiki"
For example, with the above line added, a URL such as http://localhost:3000/wiki/view?f=untitled would look like http://localhost:3000/wiki/view/untitled. This sort of URL formatting is something the Rails helper methods (such as link_to, redirect_to, url_for, and others) automatically handle for you.
You have successfully built a completely functional Wiki system, but you obviously can add to and enhance this basic system. If you are interested in learning more Rails or simply building upon the downloadable application, here are a couple of suggestions:
- Leverage the strengths of Rails and have your application persist its Wiki pages in a database (perhaps using a text data type for the actual Wiki text).
- Add search capabilities to the application using an existing Ruby gem that provides indexing and searching capabilities. For example, one such gem named Ferret can be found at ferret.davebalmain.com/trac.
- Add support for commonly found Wiki features such as WikiWord, change history, and so on.
Apart from that, have fun coding with Ruby and Rails!