title: undefined local variable or method `user'
body: <p>I am trying to do the following: </p>
  
  <p><strong>index.html.erb</strong></p>
  
  <pre><code>&lt;div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"&gt;&lt;/div&gt;
  
  &lt;script&gt;
      $(function () {
          var chart;
          $(document).ready(function () {
              chart = new Highcharts.Chart({
                  chart:{
                      renderTo:'container',
                      type:'column'
                  },
                  title:{
                      text:'&lt;%= Date.today.strftime("%B")%&gt; Overtime'
                  },
                  xAxis:{
                      categories:[
  
                          '&lt;%= Date.today.strftime("%B")%&gt;'
  
                      ]
                  }, 
                  yAxis:{
                      min:0,
                      title:{
                          text:'Hours'
                      }
                  },
                  legend:{
                      layout:'vertical',
                      backgroundColor:'#FFFFFF',
                      align:'left',
                      verticalAlign:'top',
                      x:100,
                      y:70,
                      floating:true,
                      shadow:true
                  },
                  tooltip:{
                      formatter:function () {
                          return '' +
                                  'Hours' + ': ' + this.y;
                      },
  
                      credits:{
                          text:'migroup-.co.uk',
                          hreft:'http://wwww.migroup.co.uk'
                      }
                  },
                  plotOptions:{
                      column:{
                          pointPadding:0.4,
                          borderWidth:0
                      }
                  },
  
  
                  series:[
                      &lt;% @user.hospital_bookings.each do |hospital_booking| %&gt;
  
                      {
                          name:'&lt;%= hospital_booking.try(:name)%&gt;',
                          data:[&lt;%= hospital_booking.sum(&amp;:overtime)%&gt;
  
  
                          ]
                          // color: '#8F8689',
                      },
                      &lt;% end %&gt;
                      {
                          name:'Total',
                          data: [&lt;%= @hospital_bookings.to_a.sum(&amp;:overtime)%&gt;],
                          color:'#FE9D00'
                      }
                  ]
              });
          });
  
      });
  
  
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>controller.rb</strong></p>
  
  <p>def index</p>
  
  <pre><code>@user = User.all
  @hospital_bookings = HospitalBooking.scope
  </code></pre>
  
  <p>end
  end</p>
  
  <p>What I am trying to do is for each user, iterate over their bookings and sum their <code>overtime</code>. </p>
  
  <p>Models</p>
  
  <pre><code>User.rb 
  has_many :hospital_bookings 
  
  Hospital_booking
  belongs_to :user
  </code></pre>
  
  <p>What this will effectively do is get the user and sum their overtime hours. But for some reason this is not working. What I have at the moment is highcharts looking like the forward: </p>
  
  <p><a href="http://i.imgur.com/dhGgzGz.png" rel="nofollow">Imgur</a>. Each bar represents a seperate hospital booking and their overtime. However I'd like to just total that Users overtime. So effectively it has one bar per user. </p>