It turns out that it is very easy to customise the error message header.
Goto config/locales
open up en.yaml and paste the following into it
"en":
activerecord:
errors:
template:
header:
one: "{{model}} is not valid"
other: "There are {{count}} errors prohibiting this {{model}} from being saved"
# The variable :count is also available
body: "The following fields have problems:"
Edit the text as you require and save the file.
That's it
Damian Jones
Feature: In order to develop as a developer I develop.
Monday, 2 November 2009
Friday, 30 October 2009
Autotest colours on windows
This is how to get autotest in colour on a windows box.
First of all ensure you have the win32console and term-ansicolor gems, and obviously zentest.
Then if you don't have the file .autotest in the root of your application, create it and put the follwing require into it
require 'Win32/Console/ANSI'
and viola! lovely coloured specs, not as nice as youd ghet on a mac, but if you have to put up with windows, it makes life that little bit nicer.
First of all ensure you have the win32console and term-ansicolor gems, and obviously zentest.
Then if you don't have the file .autotest in the root of your application, create it and put the follwing require into it
require 'Win32/Console/ANSI'
and viola! lovely coloured specs, not as nice as youd ghet on a mac, but if you have to put up with windows, it makes life that little bit nicer.
Thursday, 17 September 2009
First attempt at an Erlyweb application using YAWS and MySql
After a couple of days reading and re-reading the erlyweb blogs and posting to StackOverflow I have finally got my first Erlyweb app up and running. Before I foget it all and have to go through the same trouble again I am going to record all the steps and issues I came across.
I am working on a windows box and I am guessing this is the main reason I had so many problems together with the fact that I only started learning Erlang two weeks ago.
Anyway, this is what I did.
I was working from Yariv's Erlyweb music blog and had already downloaded Erlang, Erlyweb and YAWS. I placed the precompiled erlyweb library into the erlang lib directory and installed YAWS using the windows installer. This placed YAWS into the program files directory, which caused me many issues (however easy to overcome)
To get the music app to work after following the instructions exactly from Yariv's blog I had to add the following lines to my yaws.conf file, found in the root of the YAWS installation directory.
After adding these two lines I was able to navigate to http://localhost:8000/music/musician/new and saw a nicely generated input form for a new musician, however when I tried to save that form I got a nasty YAWS error that I didn't really understand apart from I new it had something to do with accessing the MySql db. I eventually realised that I was running my MySql process in a seperate shell to YAWS.
So in my YAWS shell I entered from following
In order to compile and start the MySql connection with just one command place the following file into the root of the application.
Compile this module c(start).
Start yaws, change directory to the root of your app and type start:boot().
Now onto investigating mnesia and putting some of my own Erlang code into the Models, Views and Controllers.
Hope this helps someone. I will be back with my next developments very soon.
Anyway, this is what I did.
I was working from Yariv's Erlyweb music blog and had already downloaded Erlang, Erlyweb and YAWS. I placed the precompiled erlyweb library into the erlang lib directory and installed YAWS using the windows installer. This placed YAWS into the program files directory, which caused me many issues (however easy to overcome)
To get the music app to work after following the instructions exactly from Yariv's blog I had to add the following lines to my yaws.conf file, found in the root of the YAWS installation directory.
ebin_dir="C:\Program Files\erl5.7.2/lib/erlyweb-0.7.1/ebin"
ebin_dir="C:/Program Files/Yaws-1.84/applications/music/ebin"
The first line tells YAWS where to find the erlyweb library and the second line tells it where to find my application ebin folder containing all the compiled erlang for my application.After adding these two lines I was able to navigate to http://localhost:8000/music/musician/new and saw a nicely generated input form for a new musician, however when I tried to save that form I got a nasty YAWS error that I didn't really understand apart from I new it had something to do with accessing the MySql db. I eventually realised that I was running my MySql process in a seperate shell to YAWS.
So in my YAWS shell I entered from following
12> erlydb:start(mysql, [
{hostname, "localhost"},
{username, "musicuser"},
{password, "password"},
{database, "music"}
]).
and voila it all works, I can create, edit, delete and list musicians and I didn't write a line of code, all created for me ina Rails scoffold style. (btw, the mysql driver does not like empty passwords so watch out for that)In order to compile and start the MySql connection with just one command place the following file into the root of the application.
-module(start).
-export([boot/0, boot/1]).
boot() ->
boot(true).
boot(false) ->
compile();
boot(true) ->
mysql_start(),
compile().
mysql_start() ->
erlydb:start(mysql, [{hostname, "localhost"},
{username, "twoorluser"},
{password, "orgone"},
{database, "music"}]).
compile() ->
erlyweb:compile("d:/erlang/music",
[{erlydb_driver, mysql}]).
Compile this module c(start).
Start yaws, change directory to the root of your app and type start:boot().
Now onto investigating mnesia and putting some of my own Erlang code into the Models, Views and Controllers.
Hope this helps someone. I will be back with my next developments very soon.
Wednesday, 3 June 2009
Codesmith - NHibernate column mapping
When you have two or more foreign keys on a table linked to the same parent table, for example a product table could have a supplierid(fk) and a owningcompanyid(fk) both linking to the company table. The CodeSmith - Nhibernate generator would map these as Company1 and Company2, not very useful.
Get around this by adding an extended attribute to each of the columns in the database.
For example supplierid add the extended attribute cs_alias to each of the columns giving them a clearer name eg:
cs_alias Supplier (for the supplierid column)
cs_alias OwningCompany (for the owningcompanyid column)
Codesmith will then automatically rename the properties throughout the generated templates.
Get around this by adding an extended attribute to each of the columns in the database.
For example supplierid add the extended attribute cs_alias to each of the columns giving them a clearer name eg:
cs_alias Supplier (for the supplierid column)
cs_alias OwningCompany (for the owningcompanyid column)
Codesmith will then automatically rename the properties throughout the generated templates.
Subscribe to:
Posts (Atom)