Home
Rails Mongrel and Apache all together now 1 PDF Print E-mail
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



Be first to comment this article

Write Comment
  • Please keep the topic of messages relevant to the subject of the article.
  • Personal verbal attacks will be deleted.
  • Please don't use comments to plug your web site. Such material will be removed.
  • Just ensure to *Refresh* your browser for a new security code to be displayed prior to clicking on the 'Send' button.
  • Keep in mind that the above process only applies if you simply entered the wrong security code.
Name:
E-mail
Homepage
Title:
BBCode:Web AddressEmail AddressBold TextItalic TextUnderlined TextQuoteCodeOpen ListList ItemClose List
Comment:

Code:* Code
I wish to be contacted by email regarding additional comments

Powered by AkoComment Tweaked Special Edition v.1.4.6
AkoComment © Copyright 2004 by Arthur Konze - www.mamboportal.com
All right reserved

 
< Prev

Under Construction

Jibwa.com is under construction. Watch out for broken links, missing pages, potholes and bulldozers. We apologize for the temporary inconvenience - Jibwa.com Staff

News and Updates

What to do when a website breaks

Once in a while you go to check out your personal website, or to log into your company web email and you can't. For the average person going about...
Read More ...

Find how much ram and processor your computer has

Most people remember buying their computer, and usually there was a point where you had to decide based on price what processor you wanted, and how ...
Read More ...

How to see home much storage/disk space you have left

 Finding out how much space is left on your computer or how much space you have on your computer total is something very simple, but it can also ...
Read More ...

Jibwa and The Future of Computing

The staff and consultants at Jibwa LLC have been tinkering, working with, building, and developing software on compters since long before there was t...
Read More ...