I searched the Ruby on Rails forum but I could not really find an answer
to my “problem”. I’ve got a Proposal like this
class Proposal < ActiveRecord::Base
errors.add_on_empty %w( client_surname client_firstname
postal_code city )
I’ve got a NOT NULL constraint on the postal_code column (= tinyint(4)
unsigned) in the proposals database table. In the create proposal form
in the view the value in the input field is by default 0.
This makes sence because the ProposalsController creates a new Proposal
@proposal = Proposal.new
This would probably create a new proposal and set the value of
postal_code to 0. It I remove the NOT NULL constraint from the table
proposals then the input text field is empty.
Is there a way to keep the NOT NULL constraint on the postal code and
not show the default value 0 in the view?
This is probably again a discussion about keeping or removing constraint
like UNIQUE, NOT NULL, … in total from the database. I don’t think
it’s a good idea but that’s my humble opinion.