There is a great tool for making a ruby application run smoothly on Microsoft platforms. It´s called RubyScript2Exe and Tar2RubyScript. The author of both of these has made a great job explaining how to distribute a Rails app as a one click .exe with the above tools. However, the example is about three years old by now, so a small update is posted here.
The part I have changed since Erik posted the tutorial (which is using Ruby on Rails version 0.14.3) is the following. Instead of:
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"] =~ /^sqlite/
v["database"] = oldlocation(v["database"]) if v.include?("database")
v["dbfile"] = oldlocation(v["dbfile"]) if v.include?("dbfile")
end
end
end
conf
end
end
end
Since the database.yml is loaded with ERB, you´ll be fine with just modifying that file like this:
<% if defined?(TAR2RUBYSCRIPT) %>
# using tar2rubyscript
development:
adapter: sqlite3
database: <%= oldlocation("dev.sqlite3") %> # put dev.sqlite3 in the
# same dir as the .exe
production:
adapter: sqlite3
database: <%= oldlocation("db.sqlite3") %>
<% else %>
# the old configuration
...
<% end %>
When setting <%= oldlocation(“dev.sqlite3”) %> you can put your database in the same directory as the runnable .exe file and have the data stay permanently in the same db. As your .exe file extracts the actual ruby environment and your application in a temp directory, the data won´t be saved the same way as it does when setting the database path to the same directory the executable is run from.