just ram

stuff I should remember

Castle Monorail - NVelocity View Engine

I’m using the recommended view engine NVelocity.

The following objects are available to the view code: • context (IRailsEngineContext) • request • response • session • All entries in the request (if any) • All entries in the Flash (if any) • All entries in the PropertyBag (if any)

Also, a siteRoot string is added so you can build url definitions like: $siteRoot/home/index.rails <img src="$siteRoot/images/someimage.gif" />

**Notation (variable name): **

$ [ ! ][ { ][ a..z, A..Z ][ a..z, A..Z, 0..9, -, _ ][ } ]

Examples:

  • Normal notation: $mud-Slinger_9

  • Silent notation: $!mud-Slinger_9

  • Formal notation: ${mud-Slinger_9}

Loops #foreach($i in $items) #each (this is optional since its the default section) text which appears for each item #before text which appears before each item #after text which appears after each item #between text which appears between each two items #odd text which appears for every other item, including the first #even text which appears for every other item, starting with the second #nodata Content rendered if $items evaluated to null or empty #beforeall text which appears before the loop, only if there are items matching condition #afterall text which appears after the loop, only of there are items matching condition #end

Binary expressions #if($order.Status == "Undefined") Sorry, but we don't know this order. #elseif($order.Status == "Created") Your order is being processed. Hold on! #elseif($order.Status == "Dispatched") Your order has been dispatched through UPS. Cross your fingers! #end

IDictonary Parameters Calling a helper with IDictonary Paramaters: $HtmlHelper.SubmitButton("Login", $DictHelper.CreateDict("id=btnLogin"))

Subversion, TortoiseSVN and the _SVN ASP.NET Hack

Good write up of the TortoiseSVN ASP.NET Hack here

Basically involves creating an environment variable SVN_ASP_DOT_NET_HACK with the value of 1. When TortoiseSVN finds this variable it looks for _svn folder instead of .svn

Location of XML files

http://YOUR SERVER NAME:50000/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/

documents\portalResource\USER.R3_DATASOURCE.[user id]

SAP NetWeaver developer Studio – Compile Error

Was getting weird error when trying to compile a project today:

The project was not built due to "Problems encountered while copying resources.". Fix the problem, then try refreshing this project and rebuilding it since it may be inconsistent.

After a quick Google it appears this has happened to others and a re-install fixed the problem. I managed to fix the problem by:

Highlighting the project in the Enterprise Portal perspective then doing a File => Refresh from the menu.

Subversion server + windows + backup

So you want to backup your repository?

Unfortunately you cannot do a straight backup of your repository as someone may have a file open/locked which will cause problems on restore. So you should do a “hot copy” to prevent any locking issues when the actual backup is made. My “hot copy” is created using the following batch file:

REM Reset hot copy
rmdir /S /Q c:\\svnrepos_hotcopy
mkdir c:\\svnrepos_hotcopy

REM Initiate SVN backup. Use svadmin hotcopy --help for details
svnadmin hotcopy c:\\svnrepos c:\\svnrepos_hotcopy --clean-logs

I run this batch file daily as a scheduled task before the actual backup.

This batch file is a modification of the batch file described over at:

Blended Technologies

Windows SubVersion / TortoiseSVN - Compare two versions of a file

Today I needed to compare two different versions of a source file. One in the main trunk folder and the other in a previously tagged version folder. This is easily done in TortoiseSVN, snippet from the TortoiseSVN manual:

Compare two revisions of a file If you want to compare two revisions in a file’s history, for example revisions 100 and 200 of the same file, just use TortoiseSVN => Show Log to list the revision history for that file. Pick the two revisions you want to compare then use Context Menu => Compare Revisions.

If you want to compare the same file in two different trees, for example the trunk and a branch, you can use the repository browser to open up both trees, select the file in both places, then use Context Menu => Compare Revisions.

If you want to compare two trees to see what has changed, for example the trunk and a tagged release, you can use TortoiseSVN => Revision Graph Select the two nodes to compare, then use Context Menu => Compare HEAD Revisions. This will show a list of changed files, and you can then select individual files to view the changes in detail. Alternatively use Context Menu => Unified Diff of HEAD Revisions to see a summary of all differences, with minimal context.

The process of comparing two trees is really nicely done, you get a list of all the files which have been changed between the two trees. You can then drill into this list and see the changes made to individual files. Kewl!

Connecting Ruby on Rails to Microsoft SQL Server

NOTE: These instructions are now seriously out of date. You may want to check out my always up to date ebook instead. The secret of connecting Rails to Microsoft SQL Server

It appears rails does not connect to MS SQL Server right out of the box. You need to do the following to get the connection to work:

Get the latest source distribution of Ruby-DBI and copy the file:

bdi-0.1.0/lib/dbd/ADO.rb

to:

c:/ruby/lib/ruby/site_ruby/1.8/DBD/ADO/ADO.rb

NOTE: The ADO directory does not exist on a standard install, you will need to create it.

Then simply set up your railsapp/config/database.yml

Here’s an example for reference:

development:
  adapter: sqlserver
  database: database_name
  host: server_name
  username: user_name
  password: your_pw_here

Migrations ‘Zombie State’ and MS SQL

Getting ‘Zombie State’ errors with migrations and MS SQL Server? Add the following to your config/enviroment.rb:

ActiveRecord::Base.connection.instance_variable_get("@connection")["AutoCommit"] = false