Dont use sessions table in rails

I’ve just learned (the hard way ;-) ) that You should not use sessions table in DB. It is linked with some Ruby on Rails internals. Why dont use? Because somewhere in ActionPack is used instance variable @session. Using table named sessions in rails conventions mean that should exist class SessionController, and in it will be using @session to pass data to views (all generated via scaffold). Then crash happens and You will find following error:

Continue reading

Column names restrictions

Last update – 2006-05-30

Ruby on Rails praises convention over configuration. Nice, but You have to be aware of this conventions, or You may run into troubles. Let’s take DB column names. RoR makes many assumptions about them, allowing this way many magic things happen.

Currently I’m aware of following conventions:

  • column id is reserved for table primary index
  • suffix _at for datetime fields
  • suffix _on for date field
  • suffix _id for reference to other table
  • column type single table inheritance (see: RoR Wiki)
  • dont use sessions table in DB (or don’t use code generated by scaffold) details explained http://nhw.pl/wp/2006/05/30/dont-use-sessions-table-in-rails

I was not aware about type column, and doing application for import scan results from Nessus I ran on following error:

SyntaxError ((eval):1:in `compute_type': compile error
(eval):1: parse error, unexpected tINTEGER
Object::0

It was caused by type column, since DB structure was tailored to match Nessus export to SQL file, which was using such a column.

Columns named created_on and updated_at are automagically set for record creation date and update time respectively

No more google serach

As for now I have removed Google search from this blog. Why? As I wrote this blog currently is almost not indexed (I have no idea what happened). And pages which are indexed were indexed when they are on main page. Google redirects users to main page of NetManiac and there is new content. User has no chance to find interesting content for him. So I have enabled WordPress native search (long live subversion!). Less fancy, but more accurate.