Ruby on Rails and console/GUI applications
Posted by tom August 23rd, 2006
Some of you who read this blog more often will know that besides web development I’m also very interested in how I can create GUI and/or console applications using Ruby and/or Ruby on Rails.
If you want to talk from a console/GUI application with your Ruby on Rails web application you currently have only one option (as far as I’m aware of): use XMLRPC or SOAP to talk to your Rails Application. To me, this also means that if you want to instantiate a model you have to create a small wrapper class which will use XMLRPC/SOAP to talk to your Rails application.
After reading the Ruby on Rails console scripts I removed the IRB call (and some additional stuff) and ended up with this:#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/environment'
ENV['RAILS_ENV'] = ARGV.first || ENV['RAILS_ENV'] || 'development'
puts "Loading #{ENV['RAILS_ENV']} environment."
task = Task.new
task.name = "Research GUI apps"
task.description = "Research how to use Ruby on Rails without the Web"
task.save
While this not necessarily proves anything useful, I was able to instantiate my models in a non-web environment, just like the console or when unit testing.

Leave a Reply