Checkboxes and Postgres bool values

503 views
Skip to first unread message

reub...@gmail.com

unread,
Mar 13, 2009, 5:10:48 PM3/13/09
to ActiveScaffold : Ruby on Rails plugin
I'm experiencing an odd situation with toggling bool values with
checkboxes in ActiveScaffold. The checkboxes seem to toggle back and
forth between TRUE and a null / unassigned value rather than between
TRUE and FALSE.

I am using Postgresql and thought that might be the source of the
problem since postgresql seems to have 3 possible vales for bool:
TRUE, FALSE and Unassigned. Is there anyway to deal with this?
Creating a record with an initial value of FALSE works correctly, but
after that, if I change it I only get TRUE and Unassigned.


On a somewhat related issue, how can I enable inline editing while at
the same time excluding the update action? I want to get rid of the
edit link and just have this bool value toggled via checkbox from the
list view. But disabling update, prevents the bool value from being
updated in the DB when toggling the checkbox.

ser...@entrecables.com

unread,
Mar 13, 2009, 7:30:47 PM3/13/09
to actives...@googlegroups.com
On Fri, 13 Mar 2009 14:10:48 -0700 (PDT), "reub...@gmail.com"
<reub...@gmail.com> wrote:
> I'm experiencing an odd situation with toggling bool values with
> checkboxes in ActiveScaffold. The checkboxes seem to toggle back and
> forth between TRUE and a null / unassigned value rather than between
> TRUE and FALSE.

Set :null => false in your migration.

>
> I am using Postgresql and thought that might be the source of the
> problem since postgresql seems to have 3 possible vales for bool:
> TRUE, FALSE and Unassigned. Is there anyway to deal with this?

Using a drop-down box, you should be able to choose true, false or nothing
(NULL). If you want to use a checkbox and you want true or false values,
set column to NOT NULL in database.

> Creating a record with an initial value of FALSE works correctly, but
> after that, if I change it I only get TRUE and Unassigned.
>
>
> On a somewhat related issue, how can I enable inline editing while at
> the same time excluding the update action? I want to get rid of the
> edit link and just have this bool value toggled via checkbox from the
> list view. But disabling update, prevents the bool value from being
> updated in the DB when toggling the checkbox.

I'm not sure I have understood you. Do you want to have the checkbox in the
list without the edit link to edit the model? Maybe you can change the
security method for the edit link, edit won't be disabled (you can enter
the url to edit), but you can disable update for all columns apart from the
boolean column.

>

reub...@gmail.com

unread,
Mar 13, 2009, 8:04:19 PM3/13/09
to ActiveScaffold : Ruby on Rails plugin


On Mar 13, 6:30 pm, <ser...@entrecables.com> wrote:
> On Fri, 13 Mar 2009 14:10:48 -0700 (PDT), "reube...@gmail.com"
>
> <reube...@gmail.com> wrote:
> > I'm experiencing an odd situation with toggling bool values with
> > checkboxes in ActiveScaffold. The checkboxes seem to toggle back and
> > forth between TRUE and a null / unassigned value rather than between
> > TRUE and FALSE.
>
> Set :null => false in your migration.
>
>
>
> > I am using Postgresql and thought that might be the source of the
> > problem since postgresql seems to have 3 possible vales for bool:
> > TRUE, FALSE and Unassigned. Is there anyway to deal with this?
>
> Using a drop-down box, you should be able to choose true, false or nothing
> (NULL). If you want to use a checkbox and you want true or false values,
> set column to NOT NULL in database

Thanks.

>
> > Creating a record with an initial value of FALSE works correctly, but
> > after that, if I change it I only get TRUE and Unassigned.
>
> > On a somewhat related issue, how can I enable inline editing while at
> > the same time excluding the update action? I want to get rid of the
> > edit link and just have this bool value toggled via checkbox from the
> > list view. But disabling update, prevents the bool value from being
> > updated in the DB when toggling the checkbox.
>
> I'm not sure I have understood you. Do you want to have the checkbox in the
> list without the edit link to edit the model? Maybe you can change the
> security method for the edit link, edit won't be disabled (you can enter
> the url to edit), but you can disable update for all columns apart from the
> boolean column.
>
>

Yes, I just want to get rid of the edit link, but still do inline-
updates of the bool. The reason is that I don't want the user to be
able to change anything besides the bool value after the record is
created. The only other thing I can think of is if there are separate
forms for create and update. Is there any type of conditional
statement that can be called from within the helper override to
determine if it is being called for create or update?

reub...@gmail.com

unread,
Mar 13, 2009, 8:43:52 PM3/13/09
to ActiveScaffold : Ruby on Rails plugin

> > Set :null => false in your migration.

Ok, I updated my migration. Setting the bool value works correctly
from update (edit) now. However, the inline checkbox in the list mode
doesn't do anything at all now. :P It's active and ticks on/off, but
no changes in the database table.
Reply all
Reply to author
Forward
0 new messages