One of the questions raised during the last Rails training course I held was “Can Ruby on Rails work with XAMPP?”
With this new version of Rails FTW, the answer to that question is YES.
Download Rails For (the) Windows v0.1
latest version is v0.4. grab it here
OK, so this version doesn’t install mod_rails on XAMPP, but it does allow you to get around the headaches involved in making Rails 3 work with MySQL on Windows.
Here’s a basic rundown of the changes from the last installer:
- The mysql2 gem still doesn’t work for Windows so I included the old mysql gem instead.
- Like what I did with SQLite in the previous installer, I’ve included the DLL for MySQL (libmysql.dll) in the bin folder. MySQL 5.1 doesn’t work with the mysql gem so I used the DLL file from the latest “no install” package for MySQL 5.0 (mysql-noinstall-5.0.91-win32.zip).
I know, Oracle will probably sic their lawyers against us if they catch wind of this project. Hopefully the MariaDB or SkySQL guys would give us an open replacement DLL file in the future.
- I’ve modified the Railties gem to replace instances of mysql2 to mysql (e.g. database.yml, Gemfile).
- Minor change: add a line to config to remove log coloring (useless in Windows)
- Minor change: in the installer, the Add to PATH option is checked by default
- Minor change: remove gems from gem cache to reduce installer size (a facepalm moment -_-)
Rundown of the quick blog app demo using this installer below the cut.
Here’s a pic of the new Installation Destination and Optional Tasks page. It’s still using Ruby192 but now the first option is ticked by default.
(I know, I know, you might think it’s stupid to think that people studying Rails wouldn’t take the time to read the “Tick the first option” in the tutorials. Trust me, they do ignore that BOLDFACE PLEASE READ ME NOTE and click Next-Next-Install instead. Then they go ask “Why am I getting this
'ruby' is not recognized as an internal or external command.. error?!? I’m sick and tired of getting into that FML situation in the so early into training.)
While waiting for the installation to finish, we go ahead and start MySQL from XAMPP.
(Don’t have XAMPP yet? Just head over to the download page and get the XAMPP Lite version.)
Once the installation is finished, we can now open the console to build our app.
rails new APPNAME -d mysql. The
-T is for removing test code.
Now creating the scaffold.
And finally the
rake db:migrate, and the
rails server. The first 2 commands work because the root password for XAMPP is the same as the password in the default Rails 3 settings. (Here’s where I noticed that we needed to remove coloring in the logs. It’s almost 4 am here and I don’t feel like making screenshots.).
And finally the obligatory browser screenshot:
Mental note: start project on Github ASAP.