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.
Running rails new APPNAME -d mysql
. The -T
is for removing test code.
Now creating the scaffold.
And finally the rake db:create
, 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.
Hello Bryan,
Nice work done in Rails FTW. Was wondering if Ruby itself is build from source (from RubyInstaller repository) or using the binary packages available at rubyinstaller.org.
Also, where the source code of the installers can be accessed/checked, as these modifications/improvements could be reviewed and perhaps integrated back.
Thank you.
Hi Luis,
Yup, I basically just checked out RubyInstaller, installed Rails, downloaded some DLLs, did some minor changes (like changing some iss files), then packaged with whole thing with
rake ruby19:package
.Thanks to the mysql2 gem now working, the changes to the Rails gems are now pretty minimal in v0.2. Hopefully I could figure out how to automate the whole thing and upload a fork of RubyInstaller sometime soon.
Hello Bry,
Thank you for the info.
I think things could be more light for you if you just download the 7zip packages that exist and sandbox them to prepare the installers. In that way the built binaries do not differ from the official RubyInstaller ones and that reduce the chances of discrepancies.
There is interest in resurrect InstantRails:
http://accidentaltechnologist.com/instant-rails/moving-instant-rails-forward/
I believe both Rails FTW and InstantRails can benefit from this.
As for the mysql2 gem, there are some reports that might be useful get your input:
http://github.com/brianmario/mysql2/issues#issue/79
Specially in the msyql version used and the compilation options.
Thank you.
Hey Bry,
We’ve got a mailing list for a new InstantRails project. It’d be great to have you join! http://groups.google.com/group/instantrails
Nic
Thanks for the info, Nic! I think I’ll just post there the details on how we
hacked together with duct tapebuilt and packaged Rails FTW for reference. :DDuct tape was invented for a reason :)