Agile Web Development with Rails

Start from the beginning
                                        

.

Komodo (http://www.activestate.com/Products/Komodo/): ActiveState�fs IDE fordynamiclanguages,includingRuby.

. ArachnoRuby(http://www.ruby-ide.com/ruby/ruby_ide_and_ruby_editor.php): A commercialIDEforRuby.

Ask experienceddevelopers who useyourkind of operating system which edi-tor they use. Spend a week or so trying alternatives before settling in. And, once you�fve chosen an editor, make it a point of pride to learn some new fea-ture everyday.

6. Anewly createdRailsapplicationenterstheworld containing44.lesspread across36directo-ries. That�fsbefore you�fve written a thing....

Report erratum

Prepared exclusively for Jordan A. Fowler

RAILS AND DATABASES

The Desktop

I�fm notgoingtotellyouhowto organizeyourdesktopwhile working withRails, butI willdescribe whatIdo.

Mostof thetime,I�fm writingcode, runningtests, andpoking at my application in a browser. So my main development desktop has an editor window and a browser window permanently open. I also want to keep an eye on the logging that�fs generated by my application, so I keep a terminal window open. In it I use tail -f to scroll the contents of the log .le as it�fs updated. I normally run this window with a very smallfont soittakes upless space.ifI see something interesting.ashby,I zoomit up toinvestigate.

I also need accesstotheRailsAPIdocumentation, whichI viewin abrowser. In the introduction we talked about using the gem_server command to run a local web server containing the Rails documentation. This is convenient, but it unfortunately splits the Rails documentation across a number of separate documentationtrees.Ifyou�fre online,you can usehttp://api.rubyonrails.org to see a consolidated view of all the Rails documentation in one place. The sidebar describeshow to create this samedocumentation onyour own machine.

3.6 Rails and Databases

The examplesin thisbook were written usingMySQL(version5.0.22 or there-abouts).Ifyou want tofollow along with our code,it�fsprobably simplestifyou useMySQL too. Ifyoudecide to use something else,it won�ftbe a majorprob-lem.You mayhaveto make minor adjustmentsto anyexplicitSQLin our code, butRailspretty much eliminatesdatabase-speci.cSQLfrom applications.

Report erratum

Prepared exclusively for Jordan A. Fowler

RAILS AND DATABASES

Database Passwords Here�fs a note that may well prove to be controversial. You alwayswant to set a password on your production database. However, most Rails develop-ers don�ft seem to bother doing it on their development databases. In fact, most go even further down the lazy road and just use the default MySQL root user when in development too. Is this dangerous? Some folks say so, but the average development machine is (or should be) behind a .rewall. And, with MySQL, you can go a step further and disable remote access to the database by setting the skip-networking option. So, in this book, we�fll assume you�fve gone with the .ow. If instead you�fve created special database users and/or set passwords, you�fll need to adjust your connection parameters and the commands you type (for example adding the -p option to MySQL com-mands if you have a password set). For some online notes on creating secure MySQL installations for production, have a look at an article at Security Focus (http://www.securityfocus.com/infocus/1726). You need two layers of software to link your application code to the database engine. The .rst is the database driver, a Ruby library that connects the low-level database API to the higher-level world of Ruby programming. Because databases are normally supplied with interface libraries accessible from C, theseRubylibraries aretypicallywritteninC andhavetobe compiledforyour target environment.7 The second layer of code is the Rails database adapter. This sitsbetweentheRubylibraryandyour application.Eachdatabaselibrary willhaveits owndatabase-speci.cAPI.TheRailsdatabase adaptershidethese differences so that a Rails application doesn�ft need to know what kind of databaseitis running on.

You've reached the end of published parts.

⏰ Last updated: Mar 22, 2008 ⏰

Add this story to your Library to get notified about new parts!

Agile Web Development with RailsWhere stories live. Discover now