|
|
This blog describes how you can create a Rails application accessing
PostgreSQL database using
NetBeans 6.
bin directory):initdb -D "\users\Arun Gupta\postgresql\data"The files belonging to this database system will be owned by user "Arun
Gupta".<br>This user must also own the server process.<br><br>The database cluster will be initialized with locale English_United
States.1252.<br><br>fixing permissions on existing directory /users/Arun Gupta/postgresql/data
... ok<br>creating subdirectories ... ok<br>selecting default max_connections ... 100<br>selecting default shared_buffers/max_fsm_pages ... 32MB/204800<br>creating configuration files ... ok<br>creating template1 database in /users/Arun Gupta/postgresql/data/base/1 ...
ok<br>initializing pg_authid ... ok<br>initializing dependencies ... ok<br>creating system views ... ok<br>loading system objects' descriptions ... ok<br>creating conversions ... ok<br>setting privileges on built-in objects ... ok<br>creating information schema ... ok<br>vacuuming database template1 ... ok<br>copying template1 to template0 ... ok<br>copying template1 to postgres ... ok<br>
<br>WARNING: enabling "trust" authentication for local connections<br>You can change this by editing pg_hba.conf or using the -A option the<br>next time you run initdb.<br>
<br>Success. You can now start the database server using:<br><br>"postgres" -D "/users/Arun Gupta/postgresql/data"<br>or<br>"pg_ctl" -D "/users/Arun Gupta/postgresql/data" -l logfile start<br>
<br>database.yml."postgres" -D "/users/Arun Gupta/postgresql/data"LOG: database system was shut down at 2008-01-10 22:11:01<br>LOG: checkpoint record is at 0/4872F8<br>LOG: redo record is at 0/4872F8; undo record is at 0/0; shutdown TRUE<br>LOG: next transaction ID: 0/593; next OID: 10820<br>LOG: next MultiXactId: 1; next MultiXactOffset: 0<br>LOG: database system is readydatabase.yml" to match:development:<br> adapter: postgresql<br> host: localhost<br> port: 5432<br> database: RailsApplication1_Development<br> username: Arun Gupta<br> password:C:\Program Files\NetBeans 6.0\ruby1\jruby-1.0.2\bin>jruby gem install
postgres-pr<br>
Bulk updating Gem source index for: http://gems.rubyforge.org<br>
Successfully installed postgres-pr-0.4.0Tools" -> "Ruby Gems" encounters thebin directory):createdb RailsApplication1_DevelopmentCREATE DATABASEGenerate",model" from the list box and giving the name as "wish".Database Migrations", "migrate" and001_create_wishes.rb". Change "self.up"def self.up<br>
create_table :wishes do |t|<br>
t.column :greeting, :string<br>
end<br>
Wish.create :greeting => "Hello PostgreSQL!"<br>
enddb:migrate by right-clicking on the project,Run Rake Task", "db" and then "migrate".Generate...".controller".Name:" as "show" and valueViews:" as "wishes".Controllers" and open "show_controller.rb" and update thewishes" helper method as shown below:def wishes<br>
@wish = Wish.find(1).greeting;<br>
endViews", "show", "wishes.rhtml" and add the following fragment as<%= @wish %>wishes.rhtml" and hit Shift+F6 (default keystroke to run thePlease leave suggestions on other TOTD that you'd like to see. A complete
archive is available here.