Overwriting default accessors

Hi all,

Coming from the Java & Hibernate world, I was confused when trying out
this piece of line of code:
class Task < ActiveRecord::Base
  def status=(status)
    status = 'P'
    write_attribute(:status, status)

I suspect that the value of :status in the database would be P,
because I presume rails would set the attribute value first before
saving it to the database. But instead I am getting this error:
ActiveRecord::StatementInvalid: Mysql::Error: Column 'status' cannot be null

So what does overwriting default accessors used for in real life apps?
And how do we set the value before it is saved to the database in

Thank you very much in advance for the insights.