2010/5/4 Iñaki Baz Castillo <[email protected]>:
>> I can't reproduce it. Does it have a default value? Can you try to set '' to
>> that column in script/console?:
>> record = Model.new
>> record.column = ''
>> record.column
>
>
>>> c = CliOut.new
> => #<CliOut id: nil, cli: nil, client_id: nil>
>>> c.cli = 888888888
> => 888888888
>>> c.client_id = ""
> => ""
>>> c.client_id
> => nil
>>> c.save
> => true
>
>
> And the row is stored with NULL value for client_id column (which is a
> numeric column allowing NULL with NULL as default value).
>
> But if I save it in active_scaffold then it is stored with client_id = 0. ¿?


ok ok! it occurs because I'm using form_ui = :select for client_id column:

    config.columns[:client_id].form_ui = :select
    config.columns[:client_id].options = {:options => Client.array}

and array looks as follows:

  [["-", nil], ["alice", 1], ["bob", 2], ["carol", 3]

Such array is generated dynamically retrieving "id" and "name" columns
from the 'client' table. I use it to display the names of the clients
in the select.
When I select "-" then the value to store should be nil, but I think
it's converted to 0.

In fact, I've changed such array to this:

  [["-", ""], ["alice", 1], ["bob", 2], ["carol", 3]

this is, using "" instead of nil and then NULL is stored :)

So problem solved, but I wonder why it stores 0 if I give it nil value.

Thanks a lot.

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