Kayaknya ini bukan dari errtheblog, Rie/Hen. Ini dari postingannya Geoffrey Grosenbach di http://nubyonrails.com/articles/massive-list-of-rails-development-tips
--- Arie Kusuma Atmaja <[EMAIL PROTECTED]> wrote: > biasa, enjoy banget ngikutin cheatsheetnya > errtheblog > http://feeds.feedburner.com/cheatsheets > > saya ketemu pencerahan ini, saya pikir bagusnya kita > saling sharing aja disini. > dibawah ini buat poin yang saya berani komentari > maka akan saya komentari dalam > bahasa indonesia, kalau yang belum, either saya lupa > atau saya malas atau memang > nggak berani kasih komentar takut dibego'-bego'-i > sama senior dan mbah2x disini. > Jadi tolong kalau saya salah dibetuli sama > dilengkapi yg belum-belum ya. makasih > sebelumnya. > > anyway, ini rev.3 suatu hari nanti bisa aja sudah > berubah jadi selalu refer ke > original URL source. > > * Store sessions in the database. > > caranya: > # config/environment.rb: > # config.action_controller.session_store = > :active_record_store > # console: > # rake db:sessions:create > > * Use a custom configuration file for passwords and > API keys instead of storing > them in your Subversion repository. I use YAML and > mirror the style of > database.yml. > * Use constants where needed. Instead of repeating > strings like the address of > your customer service reply email, set it once in a > constant (in environment.rb > or the appropriate environment file) and use that > throughout your application. > > caranya: > liat contoh coding niwatori di toombila > environment.rb deh # kaburr > > * Keep time in UTC. A no brainer, and easy to do. > > caranya: > $ ruby -e 'puts Time.now.utc' > Fri Sep 14 21:27:43 UTC 2007 > $ ruby -e 'puts Time.now' > Sat Sep 15 04:27:49 +0700 2007 > > * Don't loop through ActiveRecord models inside > other models. Use eager loading > if you need to work with multiple associated models. > Better yet, write a custom > SQL query and let the database do the work for you. > > caranya: > pakai :include atau .find_by_sql saja langsung, > f*ck! buat yg bilang tidak elegan > kalau langsung tembak dengan query SQL langsung > > * Beware of binary fields. By default, all fields > are returned with queries, > including the full contents of any binary fields. > Use :select to pull out only > the fields you need. > > caranya: > kalo saya sih kecuali image berpiksel 50-an kali > 50-an gak ditaroh jadi blob field > di DB > > * Write tables to cache data for reports that span > months and years. It.s much > faster than re-generating a year.s worth of reports > every time a page is loaded. > > caranya: > *rtfm* baca blognya si tobi (yg bikin typo blog) > > * Create a table with a list of country names. By > default, Rails uses strings > for selects and lists of countries, which doesn.t > work well for reporting or > database consistency between models. > > caranya: > udah basi/ada di rails api. yg nggak basi either > plugin (itu juga masi non ajax) > si rick ato bikin aja lagi yg support ajax ato js > aja dah yang komplit, mis pas > pilih, jakarta, nongol jakarta selatan, trus klik, > nongol lagi, mampang, nongol > lagi, erte, erwe, kelurahan, kode pos. jadi plugin. > anyone? kerjasama sama > tukangpos sama siapa lagi nih ya? > > * Avoid bloated controllers. Instead of piling > actions into a controller, limit > yourself to 10 actions per controller, then rethink > your design. > * Keep your controllers and views skinny. In > general, most of your code should > be in your models, not your controllers or views. > * Don't store objects in the session. Use integers > or short strings if > necessary, then pull the appropriate object out of > the database for the duration > of a single request. > * Avoid heavy response processing. Can you mark a > record as needing to be > processed, then use a cron job or a messaging server > to do the long-running > work? BackgroundRB is also an option. (I use this > technique for filtering SPAM > comments on this blog). > * Use ar_mailer to queue bulk emails instead of > sending them during the Rails > response cycle. > * Monitor your servers with the > exception_notification plugin, munin, monit, or > other tools. > * Don't cut costs on hardware. You.ll quickly lose > the money you thought you > were saving if your developers have to spend even > one day a month on unexpected > server maintenance due to poor backups or cheap > hardware. > * Test-drive your development. > > * Use database indexes to speed up queries. Rails > only indexes primary keys, so > you.ll have to find the spots that need more > attention. > > caranya: > jangan lupa untuk add_index :fieldnya, :tabelnya > > * Profile your code. The ruby-prof gem and plugin > helped me make an application > three times faster with only minimal changes to the > code. > * Minimize graphic-related dependencies. If your > application only needs to make > a few thumbnails, don.t waste memory by importing > large graphics libraries. Look > at mini-magick or image_science for lightweight > thumbnailing. > * Avoid excessive repeated rendering of small > partials. > * Use CSS instead of inline tags to apply selective > styling. > > ada yang mau mendebat ini dan membandingkan dengan > CSS dan JS inline kriptik2x > yang diimplementasikan di Google? # view source deh. > > * Don't use ActiveRecord.s serialize option to store > large objects in database > fields. > > tips: > pakai ruby marshalling, atau kalau di postgres > pasang tipe array field > # ciiiyeh yg lagi mabok ma postgres! baru belajar > mulu' dari seabad lalu' :-P > > * Use attr_protected :fieldname in models to keep > database fields from being > manipulated from forms (or from any calls to > Model.update_attributes(params[:model])). > > ya, bikin field "jadi-jadian" (virtual gitu) > > * Use Ruby classes and inheritance to refactor > repeated controller code. > > barangsiapa yang sering pernah pakai eval seperti > widi dan arie, jalankan flog, > lihatlah seberapa berdarah-darah kode ruby-nya. hayo > bertobatlah! > > * Use unobtrusive Javascripting techniques to > separate behavior from markup. > * Package self-sufficient classes and modules as > plugins or RubyGems. > * Cache frequently accessed data and rendered > content where possible. > * Write custom Test::Unit assertions or rSpec > matchers to help with debugging > test suite errors. > * Rotate the Rails and Mongrel logfiles using the > logrotate daemon on Linux. > * Build a reliable backup system. > * Automate deployment and maintenance with > Capistrano or Vlad. > * Keep method bodies short. If a method is more than > 10 lines long, it.s time to > === message truncated === ____________________________________________________________________________________ Check out the hottest 2008 models today at Yahoo! Autos. http://autos.yahoo.com/new_cars.html

