Skip to main content

Posts

Showing posts from February, 2008

Mail labels and letter templates for jasperreports

The following are free (MIT license) mailing labels and letter templates for jasperreports that you can download and use in jasperserver and/or ireport: Update 3/15/2011 : I moved the Mail templates zip file here . Please consider making a small donation if the templates are of help to you, Thank you! If you need more information on how to use those templates please leave a comment in the blog.

Deployed a jruby on rails application on both Glassfish and Tomcat using Goldspike

Update 4/19/08: make sure you have rake 7.x instead of the newer 8.x version! Update 6/7/08: It does work with the latest Rake! please make sure you don't have a file in your folder whose name has a parentheses or a space when creating the WAR file. It is possible to deploy a jruby on rails application on both Glassfish and Tomcat. Make sure you read the Goldspike wiki and follow all the directions. Also make sure that you create a project WIHTOUT support for war deployment and instead install the goldspike manually. Also make sure your application works in production mode in Mongrel before you try to deploy it, that will save you a lot of time chasing ghost errors (both Glassfish and Tomcat are not very good spewing rails related errors). Also make sure that all your files are being deployed and that if you refer to any file in your application folder you use the RAILS_ROOT constant to get the absolute path. I was opening a file using a relative path, the file was on the root

How to make your Jrails application run in Glassfish v2

Using Netbeans 6.0, Create a Rails application WITHOUT support for WAR deployment. Glassfish will use the "production" part of database.yml, so make sure you have a valid configuration there. Install the goldspike plugin (script/plugin install http://jruby-extras.rubyforge.org/svn/trunk/rails-integration/plugins/goldspike ) In Netbeans, refresh the rake tasks. Add your dependent gems in the war.rb file located in config folder (see http://wiki.jruby.org/wiki/Goldspike for more instructions on how to do that). Basically is something like: add_gem 'activerecord-jdbcpostgresql-adapter' add_gem 'fastercsv' run rake->war->standalone->create from the menu. copy and paste the generated war file (should be in the app's root folder) into the autodeploy folder of you glassfish domain's (domains/yourdomain) folder. start your glassfish server. Navigate to your application, e.g.: http://localhost:8080/finances/categories/list.

How to call rake from ruby code

The following is a method to execute rake tasks from ruby code : #arguments can be for example db:migrate def call_rake(arguments) if RUBY_PLATFORM =~ /mswin/ rake_cmd = "rake.bat" #very important because windows will break with just "rake" else rake_cmd = "rake" end puts "calling #{rake_cmd} " + arguments puts system("#{rake_cmd} " + arguments) puts $? end Check out my Bullet on Rails project at Rubyforge.net to see how to call script generate scripts from ruby code.

Overriding conditions_for_collection from a module

When using ActiveScaffold, I had problems overriding conditions_for_collection from a module. The problem was that even tho I was overriding the instance method conditions_for_collection in the FilterFormExtensions module, I was including (using "include FilterFormExtensions") the module before inserting the activescaffold into the controller (using the active_scaffold method). Any active scaffold method that you want override using a module, make sure you include the module after inserting the active scaffold. Of course if you declare the method as an instance method of your controller, the method will be overridden regardless of whether is before or after inserting the active scaffold.