Generating Entity-Relationship Diagram for Ruby on Rails

Installation
Install graphviz (if not yet)
window http://www.graphviz.org/Download_windows.php
linux sudo apt-get install graphviz
osx brew install graphviz

Add the gem

In the project gemfile add

group :development do
  gem 'rails-erd'
end


Then execute cd PATH_OF_THE_PROJECT && bundle install

Using it
It's as simple as a bundle exec rake erd and it will generate a PDF file in the root of the app.

Using MySQL with Rails 3 on Windows

gem mysql2 ไม่ support mysql 64 bits ???

ลง mysql connector 32 bits

    http://dev.mysql.com/downloads/connector/c/


แล้วก็ ...


    gem install mysql2 -- '--with-mysql-lib="C:\Program Files (x86)\MySQL\MySQL Connector C 6.1\lib" --with-mysql-include="C:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include"


แล้วก็ ...

copy libmysql.dll จาก C:\Program Files (x86)\MySQL\MySQL Connector C 6.1\lib ไปไว้ที่ C:\Ruby193\bin นะจ๊ะ

Using MySQL with Rails 3 on Windows

    Install railsinstaller -> www.railsinstaller.org (I installed it to c:\Rails)

    Install MySQL (I used MySQL 5.5) -> dev.mysql.com/downloads/installer/

    --- for mySQL installation ---

    If you dont already have these two files installed you might need them to get your MySQL going

    vcredist_x86.exe -> http://www.microsoft.com/download/en/details.aspx?id=5555 dotNetFx40_Full_x86_x64.exe -> http://www.microsoft.com/download/en/details.aspx?id=17718

    Use default install Developer Machine

    -MySQL Server Config-
    port: 3306
    windows service name: MySQL55
    mysql root pass: root (you can change this later)
    (username: root)
    -MySQL Server Config-

    --- for mySQL installation ---

    --- Install the mysql2 Gem ---

    Important: Do this with Git Bash Command Line(this was installed with railsinstaller) -> start/Git Bash

    gem install mysql2 -- '--with-mysql-lib="c:\Program Files\MySQL\MySQL Server 5.5\lib" --with-mysql-include="c:\Program Files\MySQL\MySQL Server 5.5\include"'

    Now the gem should have installed correctly

    Lastly copy the libmysql.dll file from
    C:\Program Files\MySQL\MySQL Server 5.5\lib
    to
    C:\Rails\Ruby1.9.2\bin

    --- Install the mysql2 Gem ---




http://stackoverflow.com/questions/3608287/error-installing-mysql2-failed-to-build-gem-native-extension

RAILS MySQL ssh Tunnel

มีโทรศัพท์แจ้งมาว่า "แบท พี่เปลี่ยนวิธี connect mysql ให้ต้อง ssh tunnel นะ"
ตึ่งโป๊ะ!!! ทำไงๆๆๆ คืออะไร แค่เคยเห็นผ่านๆ แล้ว Ruby on Rails ทำไง

อันดับแรก
ssh -N -L 8888:127.0.0.1:3306 -f remote-user@remote-domain-or-ip

ใน database.yml ก็

 production:
  adapter: mysql2
  encoding: utf8
  host: 127.0.0.1
  port: 8888
  database: databasename
  username: remote-user
  password: password-remote-user


เสร็จ connect สำเร็จ ข้อมูลมา แต่ทำไมออกมาไม่เหมือนกัน
อ้าว!!! เปลี่ยนชื่อ database อีกก็ไม่บอก