On Lunes, 7 de Septiembre de 2009 19:38:42 rvhi escribió:
> Hi,
>
> I run into some issues with checkbox inplace_edit. When the box is
> checked the following params hash was sent,
>
> <hash>
>   <column>aaaa</column>
>   <action>bbbb</action>
>   <id>151</id>
>   <value>true</value>
>   <controller>cccc</controller>
> </hash>
>
> If it is unchecked, this was sent
> <hash>
>   <column>aaaa</column>
>   <action>bbbb</action>
>   <id>151</id>
>   <controller>cccc</controller>
> </hash>
>
> The current implementation seems to treat them the same. Without
> modifying the code of 'update_column', I have the following override,
>       @record.send("#{params[:column]}=", (params[:value] == 'true'))
>       @record.save
>       render :action => 'update_column'
>
> Would be better if it can be changed in the standard implementation.

update_column is used for other types, so we can't assign (params[:value] == 
'true', that code works if you only use it for checkboxes, but we can't put it 
in ActiveScaffold.

When is unchecked, params[:value] is missing, so column will be set to NULL. 
If column can't be null, the following line should put the default value.
params[:value] ||= @record.column_for_attribute(params[:column]).default 
unless @record.column_for_attribute(params[:column]).null

If your default value is true, then it doesn't work. You need override 
do_update_column in that case:
def do_update_column
  params[:value] ||= 'false' if params[:column] == 'column_with_default_true'
  super
end

>
> Please advise.
>
> 
-- 
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