messaliberty

about hulor and us

Posts Tagged ‘rails’

[JRuby on Rails on GAE/J] how-to put rubygems into a jar file to get around file limitations

December 2nd, 2009 post by ice

GAE (Google App Engine) has a limit number to the number files you can upload.
To get around this limit, we need to compress rubygems into jar files.

There may not be easy way to load rubygems in jar files with JRuby.
But with JRuby on GAE/J, it’s easy to load.

  • JRuby on Rails on GAE/J, can load rubygems in RAILS_ROOT/vendor/gems, just do require “gem-name”.
  • But rubygems often contain a lot of files and that can eat into the quota pretty quickly.
  • JRuby on GAE/J, can load rubygems from jar files.
  • Therefore it makes sense to put rubygems into jar files, and I am going to show you how step by step.

Steps:

  • install rubygems into a specific temporary directory (not into the system dir)
    • use -i option to install rugygems into a temporary directory.
    • use –no-rdoc and –no-ri options, to skip to install rdoc and ri, to reduce jar file size.
  • compress rubygems by jar command in the temporary directory.
  • add require “installed-gem.jar” line in RAILS_ROOT/config/environment.rb

(more…)

Lucky Star on Rails

November 26th, 2009 post by hiro

A few months ago, suddenly I got a message with the link below on our internal IRC channel.

Module: ActiveRecord::Serialization

Here is a screenshot.

Lucky Star on Rails

Lucky Star on Rails

You know what? Those are famous characters from the Japanese anime Lucky Star in the sample code! Wow! Hi guys in Rails core team, we can be good friends :P

How To Use Email To Create And Reply To Forums on Redmine

November 12th, 2009 post by hiro
Redmine

Redmine

We’re using Redmine not only as a BTS (Bug Tracking System), but also as a project management tool. We used combination of Basecamp and Trac until  October but now we’re trying to decide on a single tool to manage projects and issues. Of course we’ll keep using Basecamp for some projects but it seems better to use only one tool to reduce management costs. Redmine is my answer. It’s a BTS and a collaboration tool.

One huge disadvantage of Redmine when I compare it with Basecamp was email updating feature. There is no good solution on Redmine to create and reply to forum messages. Email discussions are important for messaliberty. So I wrote some code to use the email – forum messages feature on Redmine 0.8.5.

(more…)

[Rails] use DataTime class with ActiveRecord column

October 22nd, 2009 post by ice

ActiveRecord’s :datetime corresponds to ruby Time class.
But Time class can’t use old timestamps like 0001-01-01 00:00:00.
(ActiveRecord converts 0001-01-01 00:00:00 to 2001:01:01 00:00:00.)

So overwrite ActiveRecord to use DateTime class with :datetime.

Test Environment:

  • Ubuntu 9.04
  • ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]
  • rails 2.3.2 – 2.3.4
  • mysql Ver 14.12 Distrib 5.0.75, for debian-linux-gnu (i486) using readline 5.2

Just put following code active_record_datetime_ext.rb into RAILS_ROOT/config/initializers
(more…)

[Ruby on Rails] Didn't apply edited view file

May 18th, 2009 post by ice

With Ruby on Rails 2.3.2

Sometimes, edit rails view file like app/view/users/edit.html.erb, but didn’t apply it.
Draws page with old (before edit) view.

Reason

In app/view/* directory, like app/view/users,
there might be files like edit.html.erb.~BASE~ ends with “.html.erb.*”.
Then rails draw pages with view file that ends with “.*”.

svn (subversion) makes .~BASE~ files when compare working file with old revision file.

How to resolve

remove .*~BASE~ files like this:

 % cd project_dir
 % find . -name "*html.*"
 ./app/views/userss/edit.html.erb.~BASE~
 ./app/views/userss/show.html.erb.~BASE~
 % find . -name "*.~BASE~" -exec rm {} \;