Menu

Thursday, June 16, 2011

Saturday, February 12, 2011

Install Ruby on Rail and mySql on Snow Leopard - Mac OS X 10.6

Original Mac $PATH 
- /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

Install Xcode

Install Ruby on Rail and mySql
1. Followed this link 
http://hivelogic.com/articles/compiling-ruby-rubygems-and-rails-on-snow-leopard 

and do step 1: SET THE PATH

2. Type the following 
- sudo gem update --system
- sudo gem sources -a http://gemcutter.org/
- sudo gem update rails
- sudo gem install sqlite3-ruby

3. Followed this link
http://hivelogic.com/articles/compiling-mysql-on-snow-leopard

Thursday, December 16, 2010

The command used to create RoR project with Mysql

I have many versions of Rails in my computer and I want to create a RoR Project bases on Rails 3.0.3, so I must use the following commands to generate my project.
rails _3.0.3_ new rails303 --database=mysql

YOUR_PATH\rails303>bundle install


After you config username and password (that'll be used to connect to mysql database adapter) in database.yml file (YOUR_PROJECT_PATH/config/database.yml)

Type "rake db:create" in the terminal to create the database (its name is the same as you config in database.yml)

To specify the version of rails

You can specify the version of rails when you create an application by typing the following when creating a new app.
 rails _3.0.1_ new app_name 

Wednesday, December 15, 2010

Interactive Ruby (irb)

If you type "irb" in the terminal, you'll get the following screen ...


You can type a ruby code on the terminal, for example, it'll return 14 if you type 7+7.


You can also create a function. For example, function hi will print "Hello World!!!" on the screen.


Moreover, you can enter any ruby commands on the terminal.
Finally, irb'll help you to test any ruby commands without wasting your time because irb runs the ruby command immediately.

Error while installing mysql in command line (behind a proxy)

You'll encounter this error while enter "gem install mysql" command if your proxy requires authentication (you behind a proxy), so you need to include your proxy server into the command "gem install --http-proxy http://USERNAME:PASS@HOST:PORT mysql".

OR For installing another gem : "gem install --http-proxy http://USERNAME:PASS@HOST:PORT gem_name"

Bundle install

This is my solution. It may has a better solution than mine.

For Mac user like me, if you create the RoR project with NetBeans you need to copy the following files:

  1. config.ru
  2. Gemfile
  3. Gemfile.lock
to your project folder. These file was created from Terminal(I use this one). Otherwise, you cannot type "bundle install". The program will show "Could not locate Gemfile", if you don't do above.

Tuesday, December 14, 2010

To use another ROR project in netbeans

Note: you have to config via cmd in case that netbeans cannot generate "rake db:create or migrate" command.
1. type "bundle install"
2. open cmd in the ROR project directory then type "rake db:create" 
3. type "rake db:migrate" then run rails server via command line
4. after that you can run it as normal on your own computer

How to install RoR on Windows

1. download "rubyinstaller-1.9.2-p0" from the ROR website and set it path by click on the check box

2. install rails by  command "gem install rails"

note: you can check version by put -v after command

3. update gem by "gem update --system"

4. copy libmysql.dll from C:\Program Files\MySQL\MySQL Server 5.1\bin OR C:\Program Files\MySQL\MySQL Workbench 5.2 CE into E:\Ruby192\bin OR C:\Program Files\MySQL\MySQL Server 5.5\lib

5. install mysql by "gem install mysql"

6.download "rubygem"

7. If you encounter the above error when you enter "rake db:create" command , delete "rake.gemspec" in C:/Ruby192/lib/ruby/1.9.1/gems/specifications