Rails Mongrel and Apache all together now 1
I spent a lot of time looking at ways to run rails on Apache a few months ago. Whether or not there is an easier way to to it I think this is the best way to do it.. I am running a fully updated Redhat 5 Rackspace Server

I have done all this before but its been a while so I am just going to do a fresh application and get it runnning some basic code, and then get it live. If you already have a working app you can skip down. I do this all from a bash command line.

First I go to my rails app directory

cd /home/jbwhite/rubyprojects
mkdir photoalbum
rails photoalbum

Now Rails is installed and I have to make a mysql database and configure that.
mysql -u root -p

>create database photoalbum_development
>grant all on photoalbum_development to rbuser@localhost identified by 'password'


Now I have a database set up. And the next step is to edit my database.yml file
vim config/database.yml

There I replace the development area lines with

development:
  adapter: mysql
  database: photoalbum_development
  username: rbuser
  password: password
  socket: /var/lib/mysql/mysql.sock
  timeout: 5000

Now my rails app is running with my database. So I'll create a model.

script/generate model photo filename:string description:text

Then I'll check my migrations to be sure I typed that line in correctly.

vim db/migrate/001_create_photos.rb

That looks good so I'l update the database

rake db:migrate

And now I have a table, a model, and its time for a controller

script/generate controller photo

then edit the controller

vim app/controller/photo_controller.rb

add the lines under the header so the controller looks like this

class PhotoController < ApplicationController

  def index
        render :xml => Photo.find(:all).to_xml
  end

end

Now I want to put a little info into the database for testing so I run

script/console
>Photo.create(:filename => "imaees/jibwalogo9.pngh", :description => "Dev Logo")
>Photo.create(:filename => "imaees/jibwalogo11.pngh", :description => "Dev Logo Clean")

I made a few typos, so I deleted everything and started again

>Photo.find(:all).each do |x| {x.destroy}

>Photo.create(:filename => "images/jibwalogo9.png", :description => "Dev Logo")
>Photo.create(:filename => "images/jibwalogo11.png", :description => "Dev Logo Clean")

Now I am ready to display something. But I want it to go through apache.


I have the rest in part 2