Rails 3 and NetBeans
I’m sure everyone reading this is aware of the Oracle and Ruby on Rails saga. Whilst Oracle no longer officially provides support for Ruby and Rails in NetBeans, the task has been picked up by the JRuby community and Rails support does still exist. Rails 3, now in its second major release (3.0, 3.1) still isn’t well supported, however. This post has some workarounds I’ve pieced together.
Note: this post is a work in progress. I’ll update it with more backwards compatibility junk as I run into issues.
First up: script/server
Plonk this in a new file called “server” in the “script” directory of your application. It’ll enable NetBeans to run your application.
#!/usr/bin/env ruby
# encoding: UTF-8
# Be compatible with outdated IDEs that don't know about the rails command yet.
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
Dir.chdir(File.expand_path('../../', APP_PATH)) unless File.exists?(File.expand_path("config.ru"))
require 'rails/commands/server'
Rails::Server.new.tap { |server|
require APP_PATH
Dir.chdir(Rails.application.root)
server.start
}
Keeping your repository free of this kludge
You’ll want something like this in your .gitignore or whatever SCM tool you use:
script/server
