On Viernes, 8 de Abril de 2011 09:08:41 vhochstein escribió:
> Hi,
> 
> First of all there is no way to exclude a column from that check
> explicitly so far.
> 
> check is done in def attributes_hash_is_empty?(hash, klass)
> 
> Normally, default values should nt be used for empty check.
> # defaults are pre-filled on the form. we can't use them to determine
> if the user intends a new row.
> next true if column and value == column.default.to_s
> 
> Have you configured default value for your db column?
> If default is configured it would be great if you could debug why it
> is nt working.

Another way would be enabled :include_blank for select tag

> 
> --
> Volker
> 
> On 7 Apr., 14:26, Liehann <[email protected]> wrote:
> > Hi,
> > 
> > I have a very simple association, lets say players and bats, where a
> > player possibly has one and only one bat. Bats are a certain type, and
> > must have a unique serial number.
> > 
> > class Player
> >   belongs_to :bat
> > end
> > 
> > class Bat
> >   has_one :player
> > 
> >   validates_presence_of :serial_no
> >   validates_uniqueness_of :serial_no
> > end
> > 
> > And bat has a bat_type column. There are limited options for bat_type
> > so I configure a select:
> > 
> > class BatController < ApplicationController
> >   active_scaffold :bat do |config|
> >     config.columns[:bat_type].form_ui = :select
> >     config.columns[:bat_type].options = {:options => [['tennis',
> > 'tennis'], ['baseball', 'baseball'], ['cricket', 'cricket']]}
> >   end
> > end
> > 
> > When I create a new player a bat subform is displayed. The bat_type
> > select is displayed and 'tennis' is selected by default.
> > 
> > I click on create expecting a new player to be created. I haven't
> > filled in a bat serial number so I expect no bat to be created. What
> > happens is the bat validation fails - there is no serial number.
> > 
> > What I think is happening is the bat subform fails the "is the form
> > empty?" check because 'tennis' is selected as the bat type. Is there a
> > way to exclude the type column from the "is the form empty?" check?
> > 
> > Thanks,
> > Liehann

-- 
Sergio Cambra .:: entreCables S.L. ::.
Mariana Pineda 23, 50.018 Zaragoza
T) 902 021 404 F) 976 52 98 07 E) [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