I''m confused about the usage of
''validates_presence_of'' and the
''default'' parameter of the ''column'' method.
Let''s say I have a model
that looks something like this:
class CreateErrorTypes < ActiveRecord::Migration
def self.up
create_table :error_types do |t|
t.column :description, :string, :limit => 254, :null => false
t.column :can_delete, :boolean, :null => false, :default =>
false
end
end
def self.down
drop_table :error_types
end
end
class ErrorType < ActiveRecord::Base
validates_presence_of :description
validates_presence_of :can_delete
end
Then in console I do this:
>> ErrorType.create(:description => "General error")
What I expect is an ErrorType object with can_delete set to false, but
what I get is an error saying that can_delete "can''t be
blank". Why
isn''t it setting the default value of that field to false??
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---