Getting started with a legacy database

It’s been a few weeks, at least, since I’ve touched ruby. The plateau
I’m at is that I can view a list of dummy data through firefox, that
is, the dummy database is succesfully configured. However,
configuring <GitHub - minutils/feed-on-feeds: Released in 2003, saw the rise and fall of Google Reader, reached perfection in 2011

, which is anti-RoR, seems insurmountable.

I don’t at all mind a RTFM pointer, in fact it’d probably be helpful,
but I’ve yet to find a manual which I can follow along with on this
topic. So, any pointers as to how to break down the ORM mapping into
bite size chunks would be greatly appreadiated :slight_smile:

The schema for FoF in fact isn’t too bad, it’s really just two
tables. Would that mean two ruby objects? If so, where would the
ruby objects be defined? Each object would have the fields in the
corresponding tables?

thanks,

Thufir

Forgot to include where I’ve gotten to so far:

[thufir@localhost ~]$ ./ruby.txt

Sun Jun 10 09:30:46 BST 2007
/home/thufir
thufir
Fedora Core release 6 (Zod)
echo “”
echo “”
echo “”
echo “”
echo “”
echo “”
echo “”
echo “”
echo “”
echo “”
echo “”
echo “”
echo “”
echo “”
echo “”
echo “”
echo “”
echo “”
echo “”
echo “”
echo “”
echo “”
echo “”
echo “”
echo “”

date
pwd
whoami
cat /etc/fedora-release
cat /home/thufir/ruby.txt

echo “”
echo “”
echo “”
echo “”
echo “”
echo “”
echo “”
echo “”

echo “the database configuration file”
cat /home/thufir/dummy/config/database.yml

echo “”
echo “”
echo “”
echo “”
echo “”
echo “”
echo “”
echo “”
echo “”
echo “”
echo “”
#echo “rails dummy…”
#rails dummy

echo “”
echo “”
echo “”
#echo “ruby /home/thufir/dummy/script/generate controller hello…”
ruby /home/thufir/dummy/script/generate controller hello

echo “”
echo “”
echo “”
echo “hello world” > /home/thufir/dummy/app/views/hello/index.rhtml

echo “”
echo “”
echo “”
#echo “ruby /home/thufir/dummy/script/generate scaffold dummy…”
ruby /home/thufir/dummy/script/generate scaffold dummy

echo “”
echo “”
echo “”
#echo “ruby script/server…”

echo “http://localhost:3000/dummies/list

echo “”
echo “”
echo “”
echo “”

ruby /home/thufir/dummy/script/server

the database configuration file

MySQL (default setup). Versions 4.1 and 5.0 are recommended.

Install the MySQL driver:

gem install mysql

On MacOS X:

gem install mysql – --include=/usr/local/lib

On Windows:

gem install mysql

Choose the win32 build.

Install MySQL and put its /bin directory on your path.

And be sure to use new-style password hashing:

http://dev.mysql.com/doc/refman/5.0/en/old-client.html

development:
adapter: mysql
database: dummy
username: feeds
password: password
socket: /var/lib/mysql/mysql.sock

Warning: The database defined as ‘test’ will be erased and

re-generated from your development database when you run ‘rake’.

Do not set this db to the same as development or production.

test:
adapter: mysql
database: dummy
username: feeds
password: password
socket: /var/lib/mysql/mysql.sock

production:
adapter: mysql
database: dummy
username: feeds
password: password
socket: /var/lib/mysql/mysql.sock

  exists  app/controllers/
  exists  app/helpers/
  exists  app/views/hello
  exists  test/functional/

identical app/controllers/hello_controller.rb
identical test/functional/hello_controller_test.rb
identical app/helpers/hello_helper.rb

  exists  app/controllers/
  exists  app/helpers/
  exists  app/views/dummies
  exists  app/views/layouts/
  exists  test/functional/

dependency model
exists app/models/
exists test/unit/
exists test/fixtures/
identical app/models/dummy.rb
identical test/unit/dummy_test.rb
identical test/fixtures/dummies.yml
identical app/views/dummies/_form.rhtml
identical app/views/dummies/list.rhtml
identical app/views/dummies/show.rhtml
identical app/views/dummies/new.rhtml
identical app/views/dummies/edit.rhtml
identical app/controllers/dummies_controller.rb
identical test/functional/dummies_controller_test.rb
identical app/helpers/dummies_helper.rb
identical app/views/layouts/dummies.rhtml
identical public/stylesheets/scaffold.css

http://localhost:3000/dummies/list

=> Booting WEBrick…
=> Rails application started on http://0.0.0.0:3000
=> Ctrl-C to shutdown server; call with --help for options
[2007-06-10 09:30:57] INFO WEBrick 1.3.1
[2007-06-10 09:30:57] INFO ruby 1.8.5 (2007-03-13) [i386-linux]
[2007-06-10 09:30:57] INFO WEBrick::HTTPServer#start: pid=5613
port=3000
127.0.0.1 - - [10/Jun/2007:09:31:08 BST] “GET /dummies/list HTTP/1.1”
200 6026

  • → /dummies/list
    [2007-06-10 09:31:18] INFO going to shutdown …
    [2007-06-10 09:31:18] INFO WEBrick::HTTPServer#start done.
    [thufir@localhost ~]$
    [thufir@localhost ~]$
    [thufir@localhost ~]$ mysql -u feeds -p
    Enter password:
    Welcome to the MySQL monitor. Commands end with ; or \g.
    Your MySQL connection id is 5 to server version: 5.0.27

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql> show databases;
±-------------------+
| Database |
±-------------------+
| information_schema |
| dummy |
| dummy_development |
| feeds |
| mysql |
| test |
±-------------------+
6 rows in set (0.32 sec)

mysql>
mysql> use feeds;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql>
mysql> show tables;
±----------------+
| Tables_in_feeds |
±----------------+
| contacts |
| html |
| px_feeds |
| px_items |
±----------------+
4 rows in set (0.00 sec)

mysql>
mysql> describe px_items;
±----------±-------------±-----±----±------------------
±---------------+
| Field | Type | Null | Key | Default |
Extra |
±----------±-------------±-----±----±------------------
±---------------+
| id | int(11) | NO | PRI | NULL |
auto_increment |
| feed_id | int(11) | NO | MUL | 0
| |
| timestamp | timestamp | NO | | CURRENT_TIMESTAMP
| |
| link | text | YES | | NULL
| |
| title | varchar(250) | YES | | NULL
| |
| content | text | YES | | NULL
| |
| dcdate | text | YES | | NULL
| |
| dccreator | text | YES | | NULL
| |
| dcsubject | text | YES | | NULL
| |
| read | tinyint(4) | YES | MUL | NULL
| |
±----------±-------------±-----±----±------------------
±---------------+
10 rows in set (0.05 sec)

mysql>
mysql> describe px_feeds;
±------------±-------------±-----±----±--------±---------------+
| Field | Type | Null | Key | Default | Extra |
±------------±-------------±-----±----±--------±---------------+
| id | int(11) | NO | PRI | NULL | auto_increment
|
| url | varchar(250) | NO | | |
|
| title | varchar(250) | NO | | |
|
| link | varchar(250) | YES | | NULL |
|
| description | varchar(250) | YES | | NULL |
|
±------------±-------------±-----±----±--------±---------------+
5 rows in set (0.00 sec)

mysql>
mysql> quit
Bye
[thufir@localhost ~]$
[thufir@localhost ~]$ date
Sun Jun 10 17:11:11 BST 2007
[thufir@localhost ~]$
[thufir@localhost ~]$

thanks,

Thufir