<?xml version="1.0" encoding="UTF-8"?>
<wiki>
  <body>&lt;p&gt;The &lt;code&gt;enable_active_olap&lt;/code&gt; is used to activate your model for performing &lt;span class=&quot;caps&quot;&gt;OLAP&lt;/span&gt; queries. It can just be included in your class, and you&amp;#8217;re set to go!&lt;/p&gt;
&lt;pre&gt;
class Project &amp;lt; ActiveRecord::Base
  enable_active_olap
end
&lt;/pre&gt;
&lt;h2&gt;Passing a block&lt;/h2&gt;
&lt;p&gt;However, you may use this opportunity to define some dimensions and aggregates for this class by passing a block. These can later be used in your &lt;span class=&quot;caps&quot;&gt;OLAP&lt;/span&gt; queries using the symbol that you used as name.&lt;/p&gt;
&lt;pre&gt;
class Project &amp;lt; ActiveRecord::Base
  enable_active_olap do |olap|
    
    # register a dimension using this syntax
    olap.dimension &amp;lt;:dimension_symbol&amp;gt;, &amp;lt;dimension_definition_hash&amp;gt;
    
    # register an aggregate function using this syntax
    olap.aggregate &amp;lt;:aggregate_name&amp;gt;, &amp;lt;aggregate_definition&amp;gt;

  end
end
&lt;/pre&gt;
&lt;p&gt;Note that you don&amp;#8217;t have to define these dimension here, you can actually pass complete dimension definitions to &lt;code&gt;olap_query&lt;/code&gt;. However, it usually is good practice to have all your definitions in one place. You could move them to a separate file if you wish. Moreover, you can use the short-hand names of these dimensions when calling &lt;code&gt;olap_query&lt;/code&gt;.&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;See the [[dimensions]] page to see how dimension definitions are constructed.&lt;/li&gt;
	&lt;li&gt;See [[aggregates]] to see how aggregates are defined and used.&lt;/li&gt;
	&lt;li&gt;See [[olap_query]] to see how queries are executed using dimensions and aggregates.&lt;/li&gt;
&lt;/ul&gt;</body>
  <created-at type="datetime">2008-07-31T13:33:08-07:00</created-at>
  <id type="integer">41427</id>
  <permalink>enable_active_olap</permalink>
  <repository-id type="integer">37573</repository-id>
  <title>enable_active_olap</title>
  <updated-at type="datetime">2008-08-04T13:18:55-07:00</updated-at>
  <user-id type="integer">15870</user-id>
</wiki>
