Locomotive slowing to a crawl - ruby-on-rails

I have recently been building very small and simple apps using Locomotive 2.0.8. Until now it has been the ideal solution, but recently the application has slowed to absolute crawl. It takes literally 10 minutes to boot up, 5 minutes to add an existing or new project - and often these creations don't even work correctly. I can't imagine what I have done. I have tried uninstalling Locomotive, and clearing my directories. What could be causing this? Something to do with RubyGems? any other solutions besides Locomotive? Or how can I completely uninstall Loco, gems, and all my projects and essentially format my dev environment to start anew?

Locomotive isn't really necessary anymore. You used to be a pain to get a decent ruby environment running on os x, but these days it's easy. Google for 'compiling ruby mac os x'

Another solution to getting your rails apps running is to use Pow to serve it and then use Anvil to control Pow.
Bam!

Related

How do you test Rails on Windows?

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.

How to distribute ruby on rails offline applications?

I was following the solution on this answer for distributing rails apps but it seems like it's not up to date for everything with slingshot.
I just can't get it working. Is there a new or another way to get a rails application distributed into offline exe file and .app for Mac OS X ?
I went down this path a year or two ago and didn't find any success. I couldn't ever get Slingshot to work with 2.3.x Rails apps, I even thought about deploying the application on an entire OS system wrapped up into a virtual .exe using Xenocode (which is now Spoon Studio). Ultimately, I rebuilt the back-end Ruby stuff in javascript and deployed it as an AIR app, not something I'd recommend or even do again myself.
There's another thread on this topic with some other options listed in the answers and comments:
Distributing Rails Applications as Native Applications
Good luck.

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