<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Jared Galanis | a/web/dev/blog</title>
    <description>This is the blog of Jared Galanis, a web developer working mainly in Ruby and JavaScript</description>
    <link>http://jaredgalanis.github.io/</link>
    <atom:link href="http://jaredgalanis.github.io/feed.xml" rel="self" type="application/rss+xml" />
    <pubDate>Fri, 31 Aug 2018 13:30:16 +0000</pubDate>
    <lastBuildDate>Fri, 31 Aug 2018 13:30:16 +0000</lastBuildDate>
    <generator>Jekyll v3.7.3.1</generator>
    
      <item>
        <title>Unspecified Bower Components Messing With Heroku Deployment</title>
        <description>&lt;p&gt;&lt;strong&gt;TLDR; When updating Ember make sure your bower components match what is in your bower.json file before deploying to Heroku&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I definitely underestimated how difficult it would be to keep up with these posts. I’m going to try to be more consistent in writing here and as a result I may write more often about smaller issues that I’m experiencing. Apologies in advance if they’re too specific to my builds to be very helpful to folks or overly simplistic.&lt;/p&gt;

&lt;p&gt;So this morning I worked through an issue regarding a deployment to Heroku on an Ember/Rails app that I’m building. I recently went through the process of upgrading to Ember and Ember Data to v2.10. If anyone has any issues about how to upgrade your Ember, Ember-CLI and Ember Data versions you should consult &lt;a href=&quot;https://emberigniter.com/update-latest-ember-data-cli/&quot;&gt;this awesome reference on Ember Igniter by Frank Treacy&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;When making an upgrade you may be prompted in the terminal about whether you would like to overwrite certain files in your Ember app. This choice can be a bit daunting at first, especially if you know you have made changes to a particular file, and want to keep those changes, but also don’t want to miss out on the changes that might occur in an updated version of the file is seeking the overwrite.  I usually make a copy of the file in question, for instance package.json, and allow the overwrite to occur, and then go back in to back into the file afterwards to add in any necessary customizations I may have made.&lt;/p&gt;

&lt;p&gt;Normally I get this done right and don’t have many issues. However, on the upgrade path this time around, I did experience a bit of self-inflicted pain. I updated about a week ago and resolved some initial issues and my build was working well locally all week. That was until I tried to push to our Heroku development server.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-ruby&quot; data-lang=&quot;ruby&quot;&gt;&lt;span class=&quot;ss&quot;&gt;remote:  &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;     &lt;span class=&quot;no&quot;&gt;Precompiling&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;assets&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;failed&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;remote&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;  &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;
&lt;span class=&quot;ss&quot;&gt;remote:  &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;     &lt;span class=&quot;no&quot;&gt;Push&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rejected&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;failed&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;to&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;compile&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Ruby&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;remote&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
&lt;span class=&quot;ss&quot;&gt;remote:  &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;     &lt;span class=&quot;no&quot;&gt;Push&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;failed&lt;/span&gt;
&lt;span class=&quot;ss&quot;&gt;remote: &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Verifying&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;deploy&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;ss&quot;&gt;remote:
remote: &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;	&lt;span class=&quot;no&quot;&gt;Push&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rejected&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;to&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;MY&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;APP&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Now, I love Heroku, but I also usually cringe when I see an error on deployment, because it isn’t always easy to debug where your error is actually coming from, especially when you’re not very experienced in devOps. Looking upstream in the server log a bit I saw this error which looked pretty suspicious:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-ruby&quot; data-lang=&quot;ruby&quot;&gt;&lt;span class=&quot;ss&quot;&gt;remote:        &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;The&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Broccoli&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Plugin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;SimpleConcat&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Concat&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Vendor&lt;/span&gt; &lt;span class=&quot;sr&quot;&gt;/assets/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;vendor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;js&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;failed&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;with:
remote:        &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Error&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;ENOENT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;no&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;such&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;file&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;or&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;directory&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;stat&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;SOME&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;PATH&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;TO&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;FILE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;IN&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;MY&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;CASE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;IT&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;WAS&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;BOWER&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;COMPONENT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Note, I’m leaving out the specific names of the components/files that were causing the errors here as they’re not specific to this issue. Anyway, looking at bower.json file I noticed it was looking pretty sparse. I then noticed that there were several bower components in the bower_components directory that were not in the bower.json file. I then also noticed further upstream in the server log that bower uninstall was being run for each of the components that were not referenced in the bower.json file.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-ruby&quot; data-lang=&quot;ruby&quot;&gt;&lt;span class=&quot;ss&quot;&gt;remote:        &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;bower&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;uninstall&lt;/span&gt;     &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;NAME&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;OF&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;BOWER&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;COMPONENT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Finding an old version of the bower.json file in the git repo allowed me to add those references back in easily. There were a few that I did not add back as they were outdated/unused in our project so I just pruned those components and things were back up and running in no time and the push to Heroku worked!&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-ruby&quot; data-lang=&quot;ruby&quot;&gt;&lt;span class=&quot;ss&quot;&gt;remote:        &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Asset&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;precompilation&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;completed&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;143.87&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;ss&quot;&gt;remote:        &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Cleaning&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;assets&lt;/span&gt;
&lt;span class=&quot;ss&quot;&gt;remote:        &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Running&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rake&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;assets&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:clean&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Again, sorry if this is too specific or simple for most folks to be helpful, but I’m going to keep writing about this stuff as I know how terrible it can be wasting precious time on these fixes.&lt;/p&gt;
</description>
        <pubDate>Sun, 18 Dec 2016 21:45:00 +0000</pubDate>
        <link>http://jaredgalanis.github.io/ember/2016/12/18/unspecified-bower-components-messing-with-heroku-deploy.html</link>
        <guid isPermaLink="true">http://jaredgalanis.github.io/ember/2016/12/18/unspecified-bower-components-messing-with-heroku-deploy.html</guid>
        
        <category>featured</category>
        
        
        <category>ember</category>
        
      </item>
    
      <item>
        <title>Interpreting Rails BigDecimal with Active Model Serializers and Ember</title>
        <description>&lt;p&gt;So I’m going to keep this post relatively brief. This is about an attribute type issue I was experiencing while building an ember app with a rails backend using the very helpful Active Model Serializers gem with their JSON API adapter configuration to serve data. In this project we had a Rails model with a column that was a BigDecimal data type. I had some difficulties in dealing with this data type because I was unaware of the way the Active Model Serializers treats Rails BigDecimals, combined with some mistaken assumptions about how Ember handles transformations of data types. Hopefully this can help you avoid the pain I experienced.&lt;/p&gt;

&lt;p&gt;TLDR; active model serializers return BigDecimals as a string and if you do not define a transform on your attribute in Ember you may end up working with strings when you expect numbers.&lt;/p&gt;

&lt;p&gt;When I first started working with Ember I thought that you had to define a transform for all of your attributes in a model by providing them as an argument to your attr methods. In other words, to borrow an example from the Ember Guides:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-js&quot; data-lang=&quot;js&quot;&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Model&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'ember-data/model'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;attr&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'ember-data/attr'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;default&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;extend&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;attr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'string'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;attr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'number'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;admin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;attr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'boolean'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;birthday&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;attr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'date'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;This is not the case. You do not have to define a transform for your attr methods. Ember will just pass through the value of the data it’s consuming from the server.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-js&quot; data-lang=&quot;js&quot;&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Model&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'ember-data/model'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;attr&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'ember-data/attr'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;default&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;extend&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;attr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;attr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;admin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;attr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;birthday&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;attr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Once I realized this I felt liberated from the constraint of having to explicitly define a transform for each attribute in each of my ember models (which are almost always duplicating a Rails-based model). Given the fact that some models in our projects have an ever growing list of attributes this felt especially good. Active Model Serializers seem to do a very good job at handling the treatment of most data types by default. So good in fact that I had never really had a problem with data types in Ember as they relate to our corresponding Rails models. This might cause you to think: Awesome! I’ll just not define a transform for any of my Ember attributes then.&lt;/p&gt;

&lt;p&gt;In most situations this works fine. However, I did run into an issue when attempting to use a computed macro in Ember to sum the instances of the values being returned by the Rails server from the column with the BigDecimal data type. Should be easy right? Something like this:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-js&quot; data-lang=&quot;js&quot;&gt;&lt;span class=&quot;nx&quot;&gt;Ember&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;computed&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;sum&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;someBigDecimalAttribute&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;BUT … the computed macro was returning a very strange looking number:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-js&quot; data-lang=&quot;js&quot;&gt;&lt;span class=&quot;mf&quot;&gt;99.90889&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;13&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Hrrrmm. Given that the operation of the macro is a relatively simple sum function I could not make sense of what was going on. I spent a good bit of time trying to debug this result making several mistaken assumptions, including that perhaps it had something to do with a failure to resolve promises. Eventually I realized that what I was getting was the sum of two strings:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-js&quot; data-lang=&quot;js&quot;&gt;&lt;span class=&quot;s1&quot;&gt;'99.90'&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'889.13'&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;99.90889&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;13&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;This was occurring because active model serializers was returning the BigDecimal column data as a string and Ember’s computed sum macro was just returning the summation of those strings. The most clear fix that I could think of was to explicitly define the transform on the Ember attribute as a number:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-ruby&quot; data-lang=&quot;ruby&quot;&gt;&lt;span class=&quot;ss&quot;&gt;someBigDecimalAttribute: &lt;/span&gt;&lt;span class=&quot;kp&quot;&gt;attr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;number&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Excellent, that works! The computed macro is now returning the sum of the numbers 989.03 as it should.&lt;/p&gt;

&lt;p&gt;Now this is probably obvious from the outset to many who know more about these issues than I do, but I do hope this is helpful to those newly approaching transforms in Ember and saves you a little time.&lt;/p&gt;
</description>
        <pubDate>Wed, 26 Oct 2016 21:45:00 +0000</pubDate>
        <link>http://jaredgalanis.github.io/ember/2016/10/26/interpret-bigdecimal-ember.html</link>
        <guid isPermaLink="true">http://jaredgalanis.github.io/ember/2016/10/26/interpret-bigdecimal-ember.html</guid>
        
        <category>featured</category>
        
        
        <category>ember</category>
        
      </item>
    
  </channel>
</rss>
