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

bundle install --deployment

หาก Gemfile ใช้ gem ที่ยังไม่ใช่ .gem เช่น

   

gem 'prawn', git: 'https://github.com/prawnpdf/prawn', branch: 'master'


*** อย่าลืมลง git ด้วย ถ้า source เป็น git

   
http://code.google.com/p/msysgit/downloads/list


bundle install ก็ผ่านปกติ แต่...

   
Error message:
        https://github.com/prawnpdf/prawn (at master) is not checked out. Please run `bundle install` (Bundler::GitError)


แก้ไขด้วย

   
bundle install --deployment


Rails 4.1.0 - Nginx Bad Gateway with Passenger

I'm writing a little issue tracking application, and as it's a new app I'm using the new shiny Rails 4.1.0. However, whilst the application runs fine locally using Webrick I've been unable to get it working when deployed onto a live (staging) environment running Passenger and Nginx (using the Ubuntu package available via the Phusion Passenger site).

When deployed and configured, Nginx reports a 502 Bad Gateway exception. Digging throught the Nginx error log (in /var/log/nginx), the error becomes clear:

Exception RuntimeError in Rack application object (Missing secret_key_base for 'production' environment, set this value in config/secrets.yml)

Opening secrets.yml shows that there is no value for production:

development:
  secret_key_base: **not_for_prying_eyes**

test:
  secret_key_base: **not_for_prying_eyes**

# Do not keep production secrets in the repository,
# instead read values from the environment.
production:
  secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>


You can either set an environment variable, or directly configure a value here (you can run rake secret to generate a key). Just make sure that if you do the latter, you've added secrets/yml to your .gitignore!

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.