The oldest hard-disk
Distributing Rails Applications, with migrations
Creating a executable file (.exe for windows for example) from a Ruby on Rails application isn’t something really new. There enough informations about that on the net, the best one can be found here.
Well, then why am I writing this blog? Well the manual from Erik Veenstra ist quite good, but what I didn’t find there anywhere was how to get the migrations done! I want to be able to give this .exe file to someone (or actually I was forced to do it this way) and they should be able to use the application, but when you keep updates in mind then you must have some way to also get migrations working.
I will be repeating some steps that are already mentioned in the “Distributing Rails Applications” tutorial.
First add this to the top of your environment.rb, this is a bit different then mentioned in the tutorial. Basically it should be working as mentioned in the tutorial, but in the last two days I was trying to solve this problem until late in the night and can’t really remember why I changed it
module Rails class Configuration def database_configuration conf = YAML::load(ERB.new(IO.read(database_configuration_file)).result) if defined?(TAR2RUBYSCRIPT) conf.each do |k, v| if v["adapter"] =~ /^sqlite3/ v["database"] = oldlocation(v["database"]) if v.include?("database") v["dbfile"] = oldlocation(v["dbfile"]) if v.include?("dbfile") end end else YAML::load(ERB.new(IO.read(database_configuration_file)).result) end end end end
Create a init.rn in the root of your application folder, you can remove the three “puts” lines, just added them for debug purposes.
at_exit do require "irb" require "drb/acl" require "sqlite3" end puts "Running as an RBA." if defined?(TAR2RUBYSCRIPT) puts "Runing from: " + oldlocation puts "Runing in: " + newlocation load "mig.rb" load "script/server"
As you can see there is a new “load” line which load mig.rb before starting the server. Here is where the magic happens.
Actually the mig.rb is nothing but a copy of the rake script with a extra line.
require 'rubygems' require 'rake' version = ">= 0" ARGV<<"db:migrate" gem 'rake', version load 'rake'
So what happens is that tar2rubyscript executes init.rb on startup, then the mig.rb is called which always does a rake db:migrate. This is done but manually adding “db:migrate” to ARGV, this has to be done so the script can be started with “load”, starting the script with a system command won’t work!
This is because the environment set up by tar2rubyscript will be missing and your migrations just won’t work.
Thats all! Incredible that for this answer I spend 2 long long nights. But now it works as it should, when starting it without tar2rubyscript it work’s as usual and with tar2rubyscript it works also great and I can have migrations when I send out new software versions.
The idea is that the same application is intended to run in two different environments, one being a usual ruby on rails environment on Linux with a MySQL Database and the other being sent out via CD and it must run on windows.
I could have made complete installer to install Ruby, Rubygems, SQLite, the Gems I need … and much more. This way it is much much easier and nobody has to install anything, just click the exe, open the browser and start working.
Telecommunications data retention (aka Vorratsdatenspeicherung)
As more and more countries have implemented laws about Telecommunications data retention, I would like to share my thoughts about this. So Big Brother thinks they can stop Terrorism by the use of Telecommunications data retention. But it is so easy to communicate without leaving a trace. It’s possible for everyone with a PC and a Internet connection to act as a Phone company without being registered anywhere, without anybody knowing that you even exist.
You can buy phone numbers from every corner of the world, the server can also be in any corner of the world where some laws may or may not apply.
Let me explain this with an example. Bart and Homer are a evil Terror organization
they are planing to blow something up. So Bart wants to call Homer and ask for some details about the Bomb. Let’s assume Big brother is only recording call details but not the call itself. So Bart calls an access number, this number is connected to a SIP Server (like asterisk).
Once connected to the server he enters Homers number, the server dials his number with a fake caller ID and deletes the CDR (call detail records) after the call. The call is being initiated via a company based in Germany (just an example) and the server with asterisk is somewhere else, let’s say in China.
So, what will data retention tell us after collecting all this data?
- Bart has made a call to some number, it is unknown whom this number belongs to. The number has been bought through one of several legal DID Exchnage platforms on the net where you can pay with PayPal or Credit card (which could be stolen), to find out where the number was connected would take a lot of time.
- Ask the regulation agency, of the country the number belongs to, whom this number belongs
- Ask the company owning the number who bought the number from them and the IP of the server it was connected to.
- After big brother has got this Data they would know that the number was connected to a server in China so the searching can begin once again.
- Ask the provider for Details about the owner of the server
- Ask for access to the server to search for CDR.
- No results where found since the server has been already cleaned up or destroyed etc etc.
- On the other side, big brother knows Homer got a phone call on his cell, from a number in Namibia (which of course it’s fake)
So in the end, big brother knows nothing! Of course if they record the content of the call they could have some information but there are ways of avoiding this. Like using a Softphone on a laptop with mobile internet conected to the SIP server via VPN. There are so many ways and all you need is a creditcard, no ID, no personal data, nothing.
So the state is trying to convince us that their intention is to “protect” us? I mean come on, you don’t need to be a genius to come up with something like this.




