How do you test Rails on Windows? - ruby-on-rails

I was dismayed to find that rake takes 20+ seconds to load before running my Rails tests. I searched and it seems that everything in Rails is just much slower on Windows. I tried to use spork but it doesn't work on Windows.
So how do you test Rails on Windows? How do you setup your environment?
How about continuous testing?

After a TON of searches the takeaways are:
1) Ruby (and therefore Rails) on Windows is painfully slow.
2) There's an attempt to make Ruby faster on windows (https://github.com/thecodeshop/ruby/wiki/Downloads). Although it's not as fast as in *nix, it's fast enough to work with.
So the answer is: Avoid developing Rails on Windows if you can. If you still want/have to develop on Windows then replace your Ruby files with The Code Shop's Ruby build, it will give you a workable speed.
As a side note, for all the talk about being open, embracing diversity, etc. the Ruby and Rails community is very antagonistic to people asking how to do X or Y on Windows. On my searches most of the posts I saw were to the tone of "Winblows sux00rz! get a Mac or Linux".
Update:
I got spork + autotest + growl working on Windows so testing is much faster and automated. I put the instructions in this blog post.

Related

Reverse engineering what version of ruby and rails a project was developed under

Some background:
I am new to Ruby and Rails and I've been assigned to get an already completed Ruby on Rails project to compile from source.
The project has, as far as I've been able to discover, little to no documentation on how to set it up. The developers are unavailable for me to contact.
After doing some tutorials and learning the basics I have been trying to get the code to compile and run. My platform/setup is currently:
Windows 7
Ruby 1.9.3
Rails 3.2.13
Although I am attempting to develop with a VirtualBox Ubuntu setup alongside of this because I suspect it will be easier in the long run.
Despite there being no Gemfile for this project I have managed to (I believe) pin down and install all of the necessary gem packages (hopefully compatible versions). I am now running into this issue:
in alias_method': undefined methodpath' for class `ActionController::UploadedStringIO' (NameError)
As far as my searches have led me to believe this is a bug that can occur when the versions of Ruby and Rails are not correct/incompatible?
Is there a way to "reverse engineer" what version of Ruby and Rails was used to develop this project in the first place from the code alone? Could this bug be caused by me using 3.2.13 Rails if the original developers were using 1.8.7 Ruby? It seems to me that if I can emulate their setup closely enough then the source should compile and I can get down to business.
Additionally I am using the default WEBrick server. Is there a way to determine what the original team used for the web service? Does it even matter if they used a Apache setup or are these server implementations mostly interchangeable aside from efficiency?
Thank you for your time. If you have any further advice on how to handle this sort of project I'd love to hear that too.
If there is no Gemfile, it points to the Rails app being 2.3 or earlier. As for the Web server, they are interchangeable, but there is really very little chance that they were using Webrick, due to its ability (or lack thereof) to handle many concurrent requests. Chances are, they were using mongrel, or passenger via Apache or Nginx.

Ruby on Rails RubyMine setup for win 7

I am trying to find a tutorial or a document or what ever which will show all the real steps with details how to setup my win 7 pc in order to debug - deploy a rails app through rubymine. I have found only spare pieces of the puzzle which i don't know how to connect.
I am newbie to ruby stuff, that's why i need details steps.
I will appreciate any help.
Download the rails installer.
http://railsinstaller.org
And then rubymine, and you should be good to.
That said, windows is less than ideal to do ruby develoment on. I did it for a while, and I spent to much time fighting the fact that ruby is best on a Unix based system. You can install ubuntu on a virtual machine and used than for your rails needs.
I think the best day to do this is to use vagrant. Check this http://www.confreaks.com/videos/2368-rmw2013-ready-to-code-automate-your-development-environment

How can I run a Rails 1.2.5 application on ruby 1.9?

I have a old app made on rails 1.2.5, this application have alot of access per day.
I intend to upgrade my server (a joyent accelerator) to run ruby 1.9.x and work with rails 3 but I can't stop or move this app to another server.
Have any way to run this application on ruby 1.9?
or run two ruby versions (1.8.7 and 1.9) at the same time?
or on the last case upgrade my app to work with rails 3?
Thanks.
There was quite a few patches to Rails to make it run under Ruby 1.9. I think you are up for a challenge if you try to do that. With Ruby Version Manager you can work with multiple ruby environments from interpreters to sets of gems.
Does it have to be switched over to Rails3 and Ruby 1.9?
Can you just throw you old app on a virtualized server and keep the app running as is?
The reason for my suggestion is that we just went through a similar case. A local business (a construction association) had a pair of apps developed for them 2-3 years ago (works with Rails 1.2.6). Nothing overly major (a billing app, and a bid/contractor/customer management system). Everything works, so no need to update anything.
Their hosting provider was not willing to keep an old outdated rails available in shared hosting environment. Hosting shop cited maintenance can't be streamlined, security concerns, etc. Sure enough, the same host offers to rewrite the apps for current technologies (for a price, of course).
Client wasn't happy with them. The shop that developed the apps since closed and the developers left for greener pastures. But everything works, so why reinvent the wheel, right? Client went looking for alternatives. Came to us. We sat down with the client, did some cost/benefit analysis and decided to just host in a virtualized environment (at another provider). Did that in a week (with some hick-ups): back-up, move, restore, test, everything works. And it's been working now for 3 months without any issues.
This might not work for you, but unless you need to add to the app why fix what ain't broken?
Rails 3 works with Ruby 1.8.7
Another option (apart from obvious RVM) is to leave your Ruby 1.8.7 and Rails 1.x as is and install latest JRuby and Rails 3.0 and dependent gems with jruby -S gem install rails. Ruby and JRuby gems perfectly coexist without any interference. OpenSolaris in Joyent's Accelerator is good at running Java, so you won't have much problems with it.
P.S. Btw, I won't recommend updating your Rails 1.x app to 3.x, unless you're planning to add lots of new features to it. It can be very painful, especially if you used lots of old-school gems and plugins.

Rake Test Very Slow in Windows

Why is Ruby, and Ruby on Rails (1.8.6 One Click Installer, local database) so ruddy slow on Windows?
ruby script/server - 30 seconds
rake test - 45 seconds
etc.
Yet, when I pop over to a much slower linux box, it's virtually instantaneous. I've checked everything - no significant CPU processes running, no network issues... and so on.
Heck, I'd be happy with just a verbose output that at least told me where it was breaking down. Any suggestions?
In general Ruby's MRI interpreter is just not optimized for speed on windows. You might also be running it in development mode on windows vs production mode on the other machines. Rails runs much slower in development mode since it reloads all your classes on every request.
1.8.6 is a very old ruby version. Released almost 3 years ago. You should strongly consider upgrading to 1.9 (or at least 1.8.7). Or switching to JRuby. All of these options will likely lead to a significant performance improvement.
1.8.7 should be fully compatible with 1.8.6. 1.9 has a completely new interpreter that runs 2.5 times faster (Though it has a tendency to occasionally crash on windows). JRuby may be the ideal solution for you since you can run it in either compatibility for 1.8 or 1.9 and it is very stable, but it does not support gems with C extensions and requires a different database adapter.
One last option would be to try running Rails inside of a VMWare with CentOS or another Linux distribution.
The reason is that file stat's in windows are dreadfully slow, and, since Ruby is written on Linux (and optimized for Linux), there hasn't been much work to make it faster.
Using the rubyinstaller.org (1.8.6 or 1.9.x) can make it faster--I'd recommend 1.8.6 since 1.9 has some slowdowns of its own.
If you're looking to get really aggressive, you can try my faster_gem_script gem, which tries to cache the heck out of require based look ups and thus speed things up. Do it with a scratch version of ruby, though :)
Unfortunately Jruby also isn't known for its exceedingly fast lookups. Hopefully this situation will change someday. Until then my faster_gem_script and faster_require are the only way I know of to try to get some speedup.
For a speedup you could try my loader speeder upper (helps rails run faster in doze): https://github.com/rdp/faster_require
Also checkout spork, which works in doze, and jruby also works well.
-rp
UPDATE: Thanks (in part) to some really great work on Fenix by Luis Lavena, Ruby 1.9.3-p327 is much, much faster on Windows. rake used to take 110+ seconds to execute on 1.9.3-p125, and now takes ~20 seconds on p327. Rails is finally usable on Windows!!
Use RubyInstaller to install..
I like taking this approach:
slow rails stack
In my case its
finisher_hook: 22.463 sec
That is the culprit

RoR development-environment setup

I'm interested to play around with RoR a bit. Apart from literature i should read, i'm particularly interested about how to setup development environment.
Here's a good example how to setup environment for Java from Noda Time project wiki pages.
I want something similar but for RoR.
As far as i know - unix operation systems fits way much better (have toyed on windows 1 1/2 year ago - pure nightmare). So it would be nice to get some recommendations about linux distros and how to make it run next to win7/xp.
Basically - i want to shorten endless searching and improvisation until i can play with some code.
P.s. bonus for simple sample project. :)
The single quickest way to get up and running might be to simply grab Netbeans and develop against its built-in JRuby instance. It will walk you through setting up a Rails project and even give you some nice-to-haves like autocompletion.
Baring that, the easiest method is likely to download a Linux VM Appliance pre-Customized for Rails Development and a copy of VMWare Player.
The best 2 ways to go are OS X and Linux, I use Ubuntu just because it's the nicest package that I've found (there will no doubt be a variety of opinons on this.)
For Rails, I like to not use the packages or pre-installed versions, and instead build my own so I can test against various versions of ruby if need be. Hivelogic has a nice post about how to do it for OS X 10.6.
From there, you can just run:
rails myproject
cd myproject
./script/generate scaffold post title:string body:text
rake db:migrate
rm public/index.html
./script/server --debugging
And then connect to http://localhost:3000/posts to get to your application.
Once you get more comfortable, check out running Passenger instead, so you can have multiple applications running at the same time. On OSX there's even a nice Prefpane to easily set up new sites. This also ins't too hard in Ubuntu with the examples provided in the passenger docs.
For editing the application I think the IDEs (Aptana, Netbeans, etc.) are still too heavyweight, especially for small starter projects. I like Textmate (like everyone else) for OSX and gedit with gedit-mate.
Once you're writing applications, you'll find that railsapi has the best interface for browsing all of the various methods not only in Rails, but ruby, authlogic, and a bunch of other common gems.
Lastly, you'll want to look into source control, with git being preferred in the Rails community at the moment.
Good luck!
Get VMWare player
Get ubuntu vm
If it's server version - install desktop x or whatever it's called
Mess around with sudos, visudos
Mess around with vi editor to save newly created account to sudoers list
Mess around with vertical mouse scrolling which apparently does not
work on vmware+ubuntu
Finally install netbeans
Through plugins, install ruby on rails
Some global updating
Enjoy toying
tadaaaa...
Something like that i wanted - with each point explained a bit (no doubt that my steps aren't best ones and sounds funny for those who knows).
I guess that i forgot to mention that i lack knowledge of unix systems in general too.
Anyway - got what i was looking for. :)

Resources