Showing posts with label Ruby on Rails. Show all posts
Showing posts with label Ruby on Rails. Show all posts

Saturday, April 17, 2010

Installing Fast Debugger for NetBeans 6.8 on Ubuntu 9.10

NetBeans IDE enables RoR developers to set break points in specific parts of source files. It is time consuming to use print statements to trace application development process. Because Fast Debugger uses native C extensions, gcc and some other extra packages need to be installed on your Ubuntu 9.10:

$ sudo apt-get install build-essential autoconf

Above command installed the following extra packages :
automake autotools-dev dpkg-dev fakeroot g++ g++-4.4 libstdc++6-4.4-dev m4
patch

Now you need to install ruby1.8-dev package to compile any native extensions.

$ sudo apt-get install ruby1.8-dev

Above command installed ruby1.8-dev package.
Now the ruby-debug-ide gem should build successfully.

$ gem install ruby-debug-ide
Building native extensions. This could take a while...
Successfully installed ruby-debug-ide-0.4.9
1 gem installed
Installing ri documentation for ruby-debug-ide-0.4.9...
Installing RDoc documentation for ruby-debug-ide-0.4.9...

NetBeans automatically detected Fast Debugger.$ gem list

*** LOCAL GEMS ***

actionmailer (2.3.4, 2.3.2)
actionpack (2.3.4, 2.3.2)
activerecord (2.3.4, 2.3.2)
activeresource (2.3.4, 2.3.2)
activesupport (2.3.4, 2.3.2)
linecache (0.43)
rack (1.0.1)
rails (2.3.4, 2.3.2)
rake (0.8.7)
ruby-debug-base (0.10.3)
ruby-debug-ide (0.4.9)

Thursday, May 14, 2009

Ruby on Rails MySql Connection

After creating a new ROR application by typing

>rails applicationName

command from the console, Rails creates all the required files for the newly created application.

Rails creates many folders and database related files are placed under /config folder.

It is required to add some connection info into the database.yml file which is also located under /config folder of your new Rails project.

Rails keeps database-login related data out of the application code and places that login information into database.yml file.

database.yml file contains information about database connections. That file has 3 sections for development-test-production databases.

development:
  adapter: mysql
  encoding: utf8
  reconnect: false
  database: store_development
  pool: 5
  username: user
  password: userpass
  socket: /var/run/mysqld/mysqld.sock
test:
  adapter: mysql
  encoding: utf8
  reconnect: false
  database: store_test
  pool: 5
  username: user
  password: userpass
  socket: /var/run/mysqld/mysqld.sock
production:
  adapter: mysql
  encoding: utf8
  reconnect: false
  database: store_production
  pool: 5
  username: user
  password: userpass
  socket: /var/run/mysqld/mysqld.sock

adapter: section tells Rails what kind of database you are using.
database: name of the database that you want to connect to.
username&password: let's your application to login to the database.

You need to have that specified database created previously in your DBMS for connection.

For this example store_development database needs to be created previously in your mysql rdbms.

In order to create your database tables which are corresponding to models created use Rake.Rake helps to apply the migration to your database. You tell the rake to do some task and that task gets done.

>rake db:migrate

Rake looks for all the migrations not applied to the database and applies them. When it is required to add a new column to a database table, you can also use migration.

This helps you to remember what each migration does when you come back to your application at a later time.

You can create a migration explicitly by typing the command:

>ruby script/generate migration add_address

To be able to run migrations on Ubuntu 9.04 OS, also install required libmysql-ruby module.