title: Rails 3 : Generate view using rabl
body: <p>In my Rails Application i have Two instance variables @departments and @register</p>
  
  <p>@departments =  </p>
  
  <pre><code>{
      "users": [
          {
              "departmentid": "DP11"
          },
          {
              "departmentid": "DP12"
          },
          {
              "departmentid": "DP13"
          },
          {
              "departmentid": "DP10"
          }
      ]
  }
  </code></pre>
  
  <p>@register = </p>
  
  <pre><code>{
      "attendance": [
          0,
          0,
          2,
          1
      ]
  }
  </code></pre>
  
  <p>@register contains an array .</p>
  
  <p>Is it possible to show like below format using rabl (attendancebydepartment.json.rabl) view</p>
  
  <pre><code>{
          "users": [
              {
                  "departmentid": "DP11",
                  "attendance"=0
              },
              {
                  "departmentid": "DP12",
                  "attendance"=0
              },
              {
                  "departmentid": "DP13",
                  "attendance"=2
              },
              {
                  "departmentid": "DP10",
                  "attendance"=1
              }
          ]
      }
  </code></pre>
  
  <p>My controller looks like</p>
  
  <pre><code>def attendancebydepartment
      @register = Array.new
      @departments = User.select('departmentid').uniq
      startdate = params[:startdate]
      enddate = params[:enddate]
      @count = @departments.count
      @departments.each do |d|
      @register &lt;&lt; (Register.where(:date =&gt; startdate..enddate , :departmentid =&gt; d.departmentid).sum(:one))+(Register.where(:date =&gt; startdate..enddate , :departmentid =&gt; d.departmentid).sum(:two))
      end
    end
  </code></pre>
  
  <p>Is it possible to add each department and its corresponding attendance to array,so that i can display like expected format.</p>