Tigraine
Daniel Hoelbling talks about programming

Rails with obstacles

May 26th, 2009 . by Daniel Hölbling

Important: Most of the information in this post about outdated MonoRail docs is now also outdated since I submitted a patch to the castle documentation project to fix the issues raised in this post.

Yesterday I decided to build a website with Castle.Monorail to learn another take on the MVC (besides the Microsoft one). Since the last official release of Monorail is quite outdated I just compiled the trunk version to start from the current release.

Doing so is very simple, just do a:

svn checkout http://svn.castleproject.org:8080/svn/castle/trunk

Some time ago Roelof Blom made an effort to make the build more user-friendly, so you don’t need any tools installed besides .NET to compile all castle assemblies. Just run ClickToBuild.cmd and it will invoke nant (also in SVN) etc, run a complete compile of all projects and place the output in

build\net-3.5\release

(Did I mention this is awesome? Building the trunk before was a nightmare!)

I then followed the Monorail getting-started samples from the website and was quite frustrated with how outdated that documentation really is.

Please read through the original documentation as it usually still applies, I’ll just list the things that I had to adapt for the trunk version to work:

Creating the Project Sceleton:

Registering Assemblies:

The list of assemblies to register is pretty outdated, I failed because I didn’t reference the DictionaryAdapter.
Instead you need to reference:

  1. Castle.Components.Binder.dll
  2. Castle.Components.Common.EmailSender.dll
  3. Castle.Components.DictionaryAdapter.dll
  4. Castle.Components.Validator.dll
  5. Castle.Core.dll
  6. Castle.MonoRail.Framework.dll
  7. Castle.MonoRail.Framework.Views.NVelocity.dll
  8. NVelocity.dll

HttpModule registration

Register the HttpModule is no longer needed. If you try to add

<httpModules>
  <add
      name="monorail"
      type="Castle.MonoRail.Framework.EngineContextModule, Castle.MonoRail.Framework" />
</httpModules>

to your config things will break. The EngineContextModule has disappeared from the source and is no longer needed.

Bringing ActiveRecord to the party

The configuration has changed since RC3 and you no longer need to prefix all keys with a hibernate. Things will break if you do. You’ll get a exception stating:

Could not find the dialect in the configuration

Kind of an misleading exception, once you remove the leading nhibernate. from your config values you’ll be set.

That’s all as for now, I decided to not go with a “real” database like MsSql during development but to go against a SqlLite database. To do so I changed the AR configuration to this:

<activerecord isWeb="true">
  <config>
    <add
        key="connection.driver_class"
        value="NHibernate.Driver.SQLite20Driver" />
    <add
        key="dialect"
        value="NHibernate.Dialect.SQLiteDialect" />
    <add
        key="connection.provider"
        value="NHibernate.Connection.DriverConnectionProvider" />
    <add
        key="connection.connection_string"
        value="Data Source=nhibernate.db3;Version=3" />
  </config>
</activerecord>

You then need to reference the System.Data.SQLite.dll and you’re set (grab the release from SourceForge).

Update: In case you try the SqlLite database I found SqlLite Administrator very useful for looking at the database.


  • http://www.tigraine.at/2009/06/21/imagineclub-students-for-students/ imagineClub – Students for Students | Tigraine

    [...] I’m planning to change this through writing a completely new website that does what it’s supposed to do, but also is completely open source! I decided to go with the Castle MonoRail framework on this one since I already did enough ASP.NET MVC Projects in the past. A positive side-effect of this should also be to work on the MonoRail documentation to get it updated once again. [...]

  • http://www.tigraine.at/2009/07/31/mvc-vs-monorail-action-methods/ Tigraine » Blog Archive » MVC vs MonoRail – Action Methods

    [...] OSS project, currently the best way to contribute to MonoRail is to write about it and if possible improve documentation around it. I guess that says everything about the quality/maturity of the [...]

  • http://thetvtopc.com/Cell_Phone_Directory reverse directory

    Keep up the great work – it is a must have for all