Posts filed under 'ruby on rails'
If you’re here, you are probably getting an error like this during a gem install on a windows box.
cl -c -nologo -O1 -MD -Zi -DNDEBUG -DWIN32 -D_CONSOLE -DNO_STRICT -DHAV
E_DES_FCRYPT -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DPERL_MSVCRT_READFIX -
O1 -MD -Zi -DNDEBUG -DVERSION=\”6.4\” -DXS_VERSION=\”6.4\” -IC:\Perl\lib\CO
RE BitVector.c
‘cl’ is not recognized as an internal or external command,
operable program or batch file.
NMAKE : U1077:
Stop.
The fix is easy if you have visual studio or the .NET SDK installed.
If you don’t then either go download Visual Studio Express or the .NET SDK (anyone out of 1.1, 2.0 or 3.5 should do)
Now, do a search on your local machine for ‘cl.exe’
I use the phenomenal windows desktop search engine locate32), here were the results I got.

Now all I had to do was use the nifty windows Path Editor “Path Ed” to add one of those paths to the system path variable

and that error goes away.
Only to be replaced by an even more cryptic one in my case
(I was trying to install passenger … I know I can’t, but I thought I’d try)

August 18th, 2008
Its old but I stumbled onto this just today. Zed Shaw (the creator of that ol’ faithful Ruby server mongrel) is a fan of the Apache Passenger (modrails) guys
I also met the Phusion Passenger guys and holy fucking crap are they on to something. If anyone is going to actually take on Mongrel in the hosting area it’s Passenger. The developers are super cool nice guys (unlike me) and even DHH likes their stuff. He really never liked anything I built, so hopefully those guys get more support. About the only thing keeping them from taking over is that they use forking so a few libraries that keep resources open will have serious problems. They’ll probably have to think up some kind of thing for that soon, but I think most Rails deployments could get pretty far with Passenger.
…
Honestly though, it shouldn’t be that hard to beat Mongrel since Mongrel is crippled by Ruby. What the Phusion guys are pulling off is just using Apache to do the heavy lifting and then let their module do the work to stream out to Rails. It’s not a new idea, they’re just doing a great job marketing it and educating people while keeping things simple. The kicker is that they also have support for Rack and WSGI. Now that’s fucking sexy.
Now, thats one hell of an endorsement
August 16th, 2008
I’ve been mucking around with passenger quite a bit these days. I’ve got two staging servers running it for two different projects and another running a production version of one of those projects.
In digging through the documentation I discovered two new command line tools that come included with the 2.0 version of Passenger.
From the documentation
passenger-status
One can inspect Phusion Passenger’s internal status with the tool passenger-status. This tool must typically be run as root. For example:

passenger-memory-stats
August 15th, 2008
If you’re seeing errors like this
... gems/activesupport-2.1.0/lib/active_support/core_ext/module/aliasing.rb:31:in `alias_method': undefined method `find_full_template_path' for class `ActionView::Base' (NameError)
You’re not crazy.
Active Scaffold (1.1.1) doesn’t play nice with Rails 2.1!
Go here to get an Active Scaffold version (master) that does.

August 2nd, 2008
There has never been a statue erected to honor a critic.
- Ziglar, Zig
I couldn’t believe that someone would have the gall to actually go on record with grouses as trite as these against the creators of mod_rails … but they did
Basically here are their complaints about Phusion Passenger/mod_rails
- Their product has ‘Enterprise’ in the title
- They shouldn’t be up to version 2.0 already (yes … they actually said that)
- They release FREE products ‘late’ (late being an excruciating 2 weeks)
- They’d like for them them to be more ‘modest’ (like they haven’t heard of DHH)
- The marketing seems too slick and something ‘fishy’ is going on because they’re trying to make money with an Enterprise ready version of Passenger/mod_rails?!?!
- The ‘rails community’ will not embrace mod_rails because of these laughable quibbles … I guess these guys don’t count as part of the ‘rails community’ right?
ridiculous.
PS: Note that the original ‘rant’ appeared on Ruby flow, where it was rightly eviscerated
June 16th, 2008
The kickass developers over at Phusion have released an update to Phusion passenger (or as I prefer to call it … Apache mod rails).
You can see the list of original improvements here

It seems that this particular problem with mod-rails hanging after a few hours and taking down apache with it (I experienced this in an apache deployment that I tried personally … and its a bit scary) was part of the motivation behind the original mod_rails/Passenger Release Candidate.
Updating mod_rails to to 2.0 made all my problems go away (mod_rails also had some trouble interacting with the soap4r plugin), but this update has even more fixes.
I have a site running on mod_rails that was formerly served up using 3 mongrels in a cluster and it runs a bit faster than before, but deployment and application management is obviously MUCH less of a headache.
These guys are doing something for Ruby on Rails, that I don’t think many understand the implication of, but cannot be overstated. Big cheers to the guys at Phusion!
June 16th, 2008
Just got bitten by this one in Ruby on Rails.
If you use empty? to check a hash slice that doesn’t exist you get an error, instead of the behavior of nil? which simply reports that it is actually nil …
irb(main):004:0> test = {}
=> {}
irb(main):005:0> test = {'test' => '1'}
=> {"test"=>"1"}
irb(main):006:0> test
=> {"test"=>"1"}
irb(main):007:0> test.empty?
=> false
irb(main):008:0> test[test]
=> nil
irb(main):009:0> test['test']
=> “1″
irb(main):010:0> test['test'].empty?
=> false
irb(main):011:0> test['test'].nil?
=> false
irb(main):012:0> test['testx'].nil?
=> true
irb(main):013:0> test['testx'].empty?
NoMethodError: undefined method `empty?’ for nil:NilClass
from (irb):13
irb(main):014:0>
June 16th, 2008
I ran into this problem after I installed mod-rails on a cent OS server.
To get my changes to take … I kept running
httpd -k graceful
and it kept working until, all of a sudden, it didn’t.
This was the error I got
[XXXX@XXXXXXXXX]# httpd -k graceful
httpd not running, trying to start
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:443
no listening sockets available, shutting down
unable to open logs
argh!
Then I found this marvellous blog posting on how to fix the “Address already in use: make_sock: could not bind to address - Apache - HTTPD Error”
Here is what I did. (click to enlarge)

worked like a charm too.
June 9th, 2008
undefined method `rewrite' for "":String
If you get this error, and the error message is pointing you to a “link_to” call or something similar, then you may be using an instance variable that’s called ‘@url’ too.
This blog post did talk about the problem but it seemed limited to models only. I finally discovered that, in my case, I was using ‘@url’ in the controller for the view where I was making the ‘link_to’ call.
Long story short, if you see this error, comb through your code (models, controllers and views) for any variables that are called ‘@url’ and change them.
May 16th, 2008
Dreamhost now supports the use of mod_rails on their shared hosting plans
The Phusion team contacted me with a working test version of Passenger a couple of months ago and since then DreamHost has been helping out with testing and ironing out lingering deployment issues. The Phusion team has been very helpful and responsive throughout the process and I think we will see a lot more great things from them in the future.
Now to the important part… how do you use Passenger on DreamHost?
Briefly, all you do is enable the Ruby on Rails Passenger (mod_rails) option for any existing or new web domain in the DreamHost web control panel. When you then point that domain’s web directory to the public directory of an existing Ruby on Rails application it will work automatically. For more detailed information, check out our Passenger wiki page.
May 14th, 2008
I was going through my google analytics logs today and I noticed that a lot of folks were coming to my site on Google searches for stuff like ‘print_r + ruby on rails‘.
So I figured I’d write a blog post about it, because I’ve had the same problem.
What you’re looking for is ‘inspect’.
If you have an array, hash or object that you want to take a quick-and-dirty look at just type in
objectname.inspect
and you’ll get an output of the contents of said array, hash or object.
Here is a screen capture of a quick irb session to show you how it works.

I hope this helps.
May 1st, 2008
The more I work with Ruby and Ruby on Rails, the more I begin to understand (though not necessarily agree with) a lot of the vitriol that has been aimed at PHP over the years by developers using other more rigorous languages.
A few weeks back I ran into this little speed bump while working with Ruby on Rails, where I was trying to do a multiple assignment like this
Most seasoned Rubyists will be waving their arms around and yelling “NOOOOOO!!!”
But coming from a PHP background this seemed perfectly okay to me.
Let me go off on a (relevant) tangent here and show you how the PHP code for this assignment would work
$x = $y = $z = array();
$x = 'me';
print_r($x);
print_r($y);
print_r($z);
the output from this is
me Array() Array()
Notice how the variables $y and $z remain arrays?
Now lets look at the same ruby code.

You can see that when we do an assignment of
ALL the variables point to the same array, so changing one item, changes all the other variables!
This is because arrays, hashes and certain objects are passed by reference not by value.
I say “certain” objects because the assignment
… doesn’t work the same way - as you can see above - even though the quoted string “you” is an object in Ruby.
So be careful PHPsters … this cost me a couple of hours in my project.
Hopefully you can skate around this one if you come across it.
April 29th, 2008
This one took a little bit but I finally figured it out …
@xml = render_component_as_string :controller => “quote”, :action => “xml”, :params => {:request_id => 100}
This would run the action “xml” of the controller “quote” and pass the parameter “100″ to it to do so.
Whatever would have been displayed at /quote/xml/100 is now stored in @xml
This allows you get the output from any action …. anywhere, also allowing you to pass parameters to it in the process.
Even better, this actually runs the action and its view (unlike render :action, which just renders the action view).
For more details, go to the Ruby On Rails Manual > Using components
April 17th, 2008
After weeks of anticipation , the apache module that allows you to upload your ruby on rails application to the server and have it “just work” has just been released.
I’ve just downloaded the source code from their git repository (git rocks!!) and am trying to see if it’ll install on windows.
Update: It won’t install on windows and there are no plans to ever allow it to (damned Linux elitists!!! :P).

April 11th, 2008
I was working on a Ruby on Rails project with Netbeans today when I went to fire up webbrick to test something in the app.
I immediately got an error like this
=> Booting WEBrick...
=> Rails application started on http://0.0.0.0:3000
[2008-03-18 16:36:59] INFO WEBrick 1.3.1
=> Ctrl-C to shutdown server; call with --help for options
[2008-03-18 16:36:59] INFO ruby 1.8.6 (2007-03-13) [i386-mswin32]
[2008-03-18 16:36:59] WARN TCPServer Error: Bad file descriptor - bind(2)
C:/ruby/lib/ruby/1.8/webrick/utils.rb:73:in `initialize': Bad file descriptor - bind(2) (Errno::EBADF)
from C:/ruby/lib/ruby/1.8/webrick/utils.rb:73:in `new'
from C:/ruby/lib/ruby/1.8/webrick/utils.rb:73:in `create_listeners'
from C:/ruby/lib/ruby/1.8/webrick/utils.rb:70:in `each'
from C:/ruby/lib/ruby/1.8/webrick/utils.rb:70:in `create_listeners'
from C:/ruby/lib/ruby/1.8/webrick/server.rb:75:in `listen'
from C:/ruby/lib/ruby/1.8/webrick/server.rb:63:in `initialize'
from C:/ruby/lib/ruby/1.8/webrick/httpserver.rb:24:in `initialize'
from C:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/webrick_server.rb:58:in `new'
... 7 levels...
from C:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/server.rb:39
from C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
from C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
from script/server:3
I did a quick google of the error, and the general consensus was that something was blocking port 3000.
But when I used the “netstat” command at the command line, I didn’t see anything on the port …

I was scratching my head a bit, but I went in to look at what processes were running and I discovered this ruby process …

Remember, webrick wasn’t running at this point, because it kept erroring out.
I figured that this was my problem, and on further prodding with Process Explorer, I found …

So I just killed the process and all was well with the universe

March 13th, 2008
Previous Posts