i didn't get the idea of optional_belongs(DataId, Type) to tell the truth. 
Give some code and console output, this may help to understand your case.

you should check source code of appropriate DB controller in case something 
is wrong. You can always add some trace points (i.e. io:format("something 
~p~n",[A])) , make all ChicagoBoss and then run you project to understand 
if a controller or probably you is the reason of unpredictable behaviour.

By the way, there is a native hd\1 function to get head of list.

On Wednesday, May 28, 2014 4:30:19 PM UTC+4, Neil Pahl wrote:
>
> thanks can2nac, I tried it and it seems to work okay while using mock 
> database. I'm not sure if it was behind all the problems I was having when 
> I tried to change to Mnesia. It didn't seem to be a problem with Mongodb 
> for me either.
>
> I cast the fields to string using '::string()' in the model definition for 
> vote, and then the empty field I defined using "" it it wasn't the same 
> type via the little function:
>
> optional_belongs(DataId, Type) ->
>     case head(string:tokens(DataId, "-")) =:= Type of
>         true ->
>             DataId;
>         false ->
>             ""  
>     end.
>
> head([H|_]) -> H. 
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at http://groups.google.com/group/chicagoboss.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/chicagoboss/f19ea1f2-095c-4507-9088-33733a586560%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to