starting with Instant Rails

The easiest way to get started with ROR on Windows is to use Instant Rails. Instant Rails, is a one-stop Rails runtime solution containing Ruby, Rails, Apache, and MySQL, all preconfigured and ready to run.There is no installer, you simply unzip it into the directory of your choice and run it.
The Instant Rails can be downloaded from http://rubyforge.org/frs/?group_id=904

after that follow these steps...
Unzip Instant Rails where you want it to reside. I chose C:\InstantRails
  • Make sure that the installation path (to the directory into which you unzip the archive) does not contain any space characters, and then start InstantRails.exe.
  • Start Instant Rails. Click the "OK" button to let it update the configuration file
That's all there is to it!
so u will get a window like this when u double click instantrails.exe

if you have a made a rails app , just copy paste to rails_apps in c:\InstantRails
To the left of the Apache button, there is a button that has the Instant Rails logo. Clicking this button reveals
a drop-down menu with the following options:
• Help
• Log Files
• Configure
• Rails Applications
• Restart Servers
• Stop Servers and Exit

in that click rails_application , a new window opens , showing your rails_app in that.
'check' your rails_app and click 'start with mongrel'
console opens showing your application has started..
so open a browser and go with http://localhost:3000.. now you can start with your project

xml generation using rails

hi all...
Here is how to do this:

create rails app

>> rails xml_generation -d mysql

create the database which u want to use and edit the name in database.yml
now create the model for 'xml_generation'

xml_generation>>ruby script/generate model student

edit the migration file created,

class CreateStudents < ActiveRecord::Migration
  def self.up
    create_table :students do |t|
      t.string :first_name
      t.string :last_name
      t.integer :age
      t.string :school_name
      t.timestamps
    end
    Student.create(
      :first_name => 'Monica',
      :last_name => 'Geller',
      :age  => 20,
      :school_name => 'Bhavans'
    )
  end
  def self.down
    drop_table :students
  end
end

so now we need to generate the controller,

xml_generation>>ruby script/generate controller student

after that edit the controller with these codes,

class StudentController < ApplicationController
  def create_file
    @students = Student.find(:all)
    file = File.new('dir.xml','w')
    doc = REXML::Document.new
    make = REXML::Element.new "make"
    @students.each do |s|
      first_name_node = make.add_element "FirstName"
      first_name_node.text  = s.first_name
      last_name_node = make.add_element "LastName"
      last_name_node.text  = s.last_name
      age_node = make.add_element "Age"
      age_node.text  = s.age
      school_node = make.add_element "School"
      school_node.text  = s.school_name
    end
    doc.add_element make
    file.puts doc
    file.close
  end
  
end

migrate the project

xml_generation>> rake db:migrate


time to run it

xml_generation>>ruby script/server


open a browser and goto to http://localhost:3000/student/create_file

enjoy....!