Ruby on Rails Notes

I jotted these down in a notepad a few weeks ago and wanted to get them recorded for future reference. Just some random notes for using Ruby on Rails.

  • Put validates_presence_of :title (for example) in the model for a module to require that a value be present when the new or edit form is submitted.
  • To create a new module, execute “script/generate scaffold <module_names>”. Module names should be singular. This’ll generate all the default templates for the scaffold so that you don’t have to create them from scratch.
  • In the model, use things like “has_many :categories” to describe relationships among modules/tables.
  • Like python, ruby/rails has a console thingy that you can use to test code quickly. Run scrip/console to fire it up.
  • FastCGI is a pain in the ass but is faster than CGI and seems to be better than mod_ruby. Need at some point to write up some notes on making this work well. Quick and dirty: Make sure apache user and group are set near the beginning of the file (before mod_fastcgi is loaded); make sure the fastcgi log directory isn’t in a symlinked path and that it’s chmoded to 0777; get the debug dispatch.fcgi (lost the link but can find it later), which seems less buggy; after changing dispatch.fcgi, be sure to kill all dispatch.fcgi processes.
  • Make sure you kill old sessions. If you get too many of them, your software will bog down.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s