Unable to find transform for 'float'


#1

Hi,

I’m using a rails 5 api that render exactly this:

{“data”:[{“id”:“1”,“type”:“taxes”,“attributes”:{“rate”:0.055,“context”:“whatever”}}]}

my “rate” attribute is clearly a float. In my models:

if I define “rate” attribute as float, I can’t load anything, related to my taxes. And I have this message “Error: Assertion Failed: Unable to find transform for ‘float’” and it looks stuck at class transformFor. if I define “rate” attribute as string, it loads and save very well

I use JSONAPIAdapter without fancy configuration (just a namespace). I guess I could custom my serialisation but it doesn’t look logic as I would like to have similar data-types in ember-data and rails. So I suppose this is not the default behaviour and I did something wrong.

If anybody can help…


#2

Not sure where you saw anything to do with a “float” transform, it does not exist.

See the api docs for attr


#3

ok so there are just no float or integer, I should just your number instead! Thanks


#4

If it does not exist, you can create it. ember g transform float and do your conversion like that. More here: http://emberjs.com/api/data/classes/DS.Transform.html