On Jueves, 13 de Mayo de 2010 13:36:23 Iñaki Baz Castillo escribió:
> Hi, I've created a virtual column "enabled" for model Phone. Then in
> PersonsController (has_many :phones) I have a subform for user phones.
>
> Here is the problem: when I press "edit" over a row in "persons"
> collection I see an empty form for a new possible Phone (I don't want
> to use "show_blank_record = false"). I fill nothing in that subform
> but AS fails since it considers I've filled "something". I expect it
> occurs because the virtual column has no default value in the DB table
> (of course) but initially it is checked.

If enabled were a boolean column instead of a virtual column it would work, 
because AS ignores boolean columns to check if record is filled.

>
> And such virtual field appears as checked in an empty subform because
> its value depends on the value of other column (TINYINT 0-1) which  is
> 1 by default.
>
> Is there any workaround for this? Thanks a lot.

You will have to override attributes_hash_is_empty? in your controller 
(PersonsController, shouldn't it be PeopleController?) to call 
attributes_hash_is_empty without enabled column. Put the overrided method 
after active_scaffold block:

def attributes_hash_is_empty?(hash, klass)
  super(hash.except(:enabled), klass)
end

-- 
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