This is a note to self. Remember to define all states for an object before you start referencing it.
If not, you will get an error like this:
“You have a nil object when you didn’t expect it! The error occurred while evaluating nil.entering”
This is the solution:
1 2 3 4 5 6 7 8 9 10 11 | class Squad < ActiveRecord::Base acts_as_state_machine :initial => :in_progress event :complete do transitions :from => :in_progress, :to => :completed, :guard => Proc.new {|s| !s.completed_at.blank? } end state :in_progress # This is the line I had forgotten to write state :completed, :enter => :do_complete |
Have fun with acts_as_state_machine!
And keep in mind that acts_as_state_machine is not concurrent. Read more here.

how to ignore *.php requests using Apache
I recently deployed a beta version of one of my projects.
A few days went by and then I started getting 404 email notifications to my inbox. It seems that someone was trying to exploit known PHP issues (eg. phpMyAdmin issues, as seen in the picture below)
Here is how I solved this issue:
2
3
4
5
6
ServerName example.com
DocumentRoot /path/to/example.com/current/public
RewriteEngine On
RewriteRule ^.*.php$ 404.html [R]
</VirtualHost>
This will redirect any *.php requests to your 404.html and save resources in your server.