Setting up Ruby on Rails Database Connection using SQLite (version 2 and 3) on Fedora 7
SQLite is good for development and testing, and depending on your needs production even. By default Typo uses SQLite for production. The greatest advantage is that it's light. (like duh), and very easy to deploy.
Note: There are two versions of SQLite, version 2 and 3. They produce databases which are incompatible with each other.
Version 2
Enter into the Terminal, and as root execute:
yum install gcc ruby-devel sqlite2-devel
gem install sqlite-ruby
If you see this, you want the ruby version, so select 1 (enter it in).
Select which gem to install for your platform (i486-linux)
1. sqlite-ruby 2.2.3 (ruby)
2. sqlite-ruby 2.2.3 (mswin32)
3. sqlite-ruby 2.2.2 (ruby)
4. sqlite-ruby 2.2.2 (mswin32)
5. Skip this gem
6. Cancel installation
>
Edit the file . For now we are using the
RAILS_ROOT/config/database.yml
development environment. The environment you are deploying your database should look like so.
development: adapter: sqlite dbfile: db/development.sql
Version 3
Enter into the Terminal, and as root execute:
yum install gcc ruby-devel sqlite-devel
gem install sqlite3-ruby
If you see this, you want the ruby version, so select 2 (enter it in).
Select which gem to install for your platform (i486-linux)
1. sqlite3-ruby 1.2.1 (mswin32)
2. sqlite3-ruby 1.2.1 (ruby)
3. sqlite3-ruby 1.2.0 (mswin32)
4. sqlite3-ruby 1.2.0 (ruby)
5. Skip this gem
6. Cancel installation
>
Edit the file
RAILS_ROOT/config/database.yml. For now we are using the
development environment. The environment you are deploying your database should look like so.
development: adapter: sqlite3 dbfile: db/development.sql
Conclusion
There you have it, your database is now set up!
Installing Ruby on Rails on Fedora 7
Note:
- I recommend installing Ruby on Rails via RubyGems
- As long as you have Ruby installed, you can install Ruby on Rails, just skip the step about installing Ruby.
- I have instructions if you are interested in Installing Ruby On Rails on Ubuntu.
Plan of Attack
This is a quick down and dirty guide to getting Ruby and Rails working in Fedora 7. You may notice this is installed into /tmp
, I do this because its universal on all Fedora and Linux distributions.
- Install Ruby
- Install RubyGems via source
- Install Ruby on Rails using RubyGems
- Test Rails installation
Warning:
- Certain commands need to be executed as root. Lines requiring to be run as root, begin with a hash (
#). To enter root executesu -
. - If a line begins with a dollar sign (
$), those can be run as a normal user. - If a line begins with a hash or a dollar sign, do not enter the starting hash or dollar sign into the terminal
Install Ruby
su - yum install ruby ruby-rdoc ruby-irb
Note: If you get an error, similar to the following, just wait a while and try the above command again.
Loading "installonlyn" plugin
Existing lock /var/run/yum.pid: another copy is running as pid 2321. Aborting.
Note: If you get something similar to the following, just enter y.
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID 4f2a6fd2
Importing GPG key 0x4F2A6FD2 "Fedora Project " from /etc/pki/rpm-gpg/RPM-GPG-KEY-fedora
Is this ok [y/N]:
Install RubyGems via source
Note: Latest version of RubyGems (0.9.4) as of 10th June 2007.
Enter into the Terminal:
cd /tmp wget http://rubyforge.org/frs/download.php/20989/rubygems-0.9.4.tgz tar -zxvf rubygems-0.9.4.tgz cd rubygems-0.9.4 ruby setup.rb
Install Ruby on Rails using RubyGems
Enter into the Terminal:
gem install -y rails
Note: If it fails, try executing gem update
and then execute the command above again.
Test Rails installation
Enter into the Terminal:
rails /tmp/railstest cd /tmp/railstest ./script/server
Open up Firefox and go to http://localhost:3000, a page should show up indicating a successful installation. Your basically good to go with the minor exception of a database connection.
After...
Generally you'd want some sort of database connection, with the three standards choices being.
- SQLite:
If you just want to experiment with Ruby on Rails, I'd recommend using SQLite. - MySQL
- PostgreSQL
Stay tuned!
