El Sábado, 17 de Octubre de 2009, Iñaki Baz Castillo escribió:
> Hi, a column called "prefix" in a MySQL table is VARCHAR and doesn't allow
> NULL.
> 
> I don't want this column to be managed by activescaffold so I don't include
>  it in the available columns.
> 
> But when creating a new entry for this model "Prefix", activescaffold tries
>  to sets it with NULL value so I get an error from mysql driver:
> 
> ActiveRecord::StatementInvalid (Mysql::Error: Column 'prefix' cannot be
>  null: INSERT INTO `dr_rules` (`prefix`, `priority`, `timerec`, `gwlist`,
>  `routeid`, `groupid`, `description`) VALUES(NULL, 0, NULL, '12', 0, '33',
>  'qweqweqwe')):
> 
> Probably this is a issue of ActiveRecord rather than activescaffold, I'm
> wrong?
> How could I force a default value (to empty string) in activescaffold for
> "prefix" column?
> 
> Thanks.
> 

The following workaround in the model works:


        before_save :set_default_values
        
        def set_default_values
                self.prefix = ""
        end

-- 
Iñaki Baz Castillo <[email protected]>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"ActiveScaffold : Ruby on Rails plugin" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/activescaffold?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to