This small tutorial will show how to create a configuration file and how to manage configuration of your Grails application. It will show how to Access configuration parameters Create external configuration Configure Spring for different environments Create a new environment Accessing configuration parameters The configuration of Grails is stored in grails-app/conf directory. Parameters are stored… Continue reading Playing with Grails application configuration
Category: How-to
Grails: internationalization in the service
Today I spent some time by creation of localized messages in a service. Here is a small tutorial. 1. Create your service grails create-service Local 2. Add a messageSource variable to your new service class LocalService { def messageSource } 3. Use it in a service method // Initialize parameters Object[] testArgs = {} def… Continue reading Grails: internationalization in the service
Monitoring number of SQL queries in MySQL
I have created a new application in Grails and surprisingly, in production environment it was slower than on my laptop. Production administrator found that my application generate too many SQL queries. The delay was caused by network latency. So, I had to find a way how to monitor number of SQL queries on MySQL server.… Continue reading Monitoring number of SQL queries in MySQL
Custom iterative tag in Grails with named variable
I will show you how to create an iterative Grails tag that can contain another tag. The inner tag will use variable of the iterative tag. So, we are going to implement a tag that creates n links ‘/show/1’, ‘/show/2’, etc. with description ‘Article number 1’, ‘Article number 2’ etc.: First of all, there is… Continue reading Custom iterative tag in Grails with named variable
From Mysql to Oracle: Grails application migration
Today I have finished migration of our Grails prototype. Originally we did develop it for MySQL, but the final system have to work with Oracle. This post summarize troubles and differences I was facing. User creation Since I am not Oracle administrator, it took me some time to put together script that creates user and… Continue reading From Mysql to Oracle: Grails application migration
Block level helpers in Ruby on Rails
Web developer often comes to a situation where he needs to “decorate” a block of a page. There is a simple solution and simple and elegant solution. Helpers concept in Ruby on Rails is very powerful and will be used to do the trick. Imagine, you want to create a rounded box helper similar to… Continue reading Block level helpers in Ruby on Rails
Ignore files in subversion
This is just a simple procedure how to tell subversion to ignore files or directories. cd parent_directory # Check the current setup svn proplist -v . # set the editor to edit the properties export EDITOR=vi # open up editor with the properties svn propedit svn:ignore . Text editor opens (vi in my case) Here… Continue reading Ignore files in subversion
Improve performance of MySQL driver for RoR
Last week I was working on the performance tuning of a rails application. I ran a profiler and found something very interesting. I found that there is a procedure that is called very often and takes a lot of time. % cumulative self self total time seconds seconds calls ms/call ms/call name 14.99 18.13 18.13… Continue reading Improve performance of MySQL driver for RoR
Bayes classification in Ruby made easy
Recently I was experimenting with ruby bayes classification. At first sight it looks like a difficult topic, but with the right libraries it is interesting and funny. Before you start experimenting, you have to install 3 gems. gem install classifier gem install madeleine Confirm the required stemmer gem. For the beginning, lets experiment with the… Continue reading Bayes classification in Ruby made easy
Ad-hoc fulltext search in RoR ActiveRecord
I came to a situation where I needed to search my Active record, but I did not know which field contains the information. The solution with Ferret was just three steps away… Let’s say, you want to search Stories for ‘Giant’ keyword. You have to create a Ferret index in memory (ferret gem needs to… Continue reading Ad-hoc fulltext search in RoR ActiveRecord