examples/introduction/index.html in acts_as_api-0.3.8 vs examples/introduction/index.html in acts_as_api-0.3.9

- old
+ new

@@ -1,10 +1,13 @@ <!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8"> <title>acts_as_api</title> + <meta content="A Ruby/Rails gem to easily generate web api reponses!" name="description" /> + <meta content="Christian Bäuerlein" name="author" /> + <meta content="en" name="language" /> <link rel="stylesheet" href="./docco.css"> <link href="http://fonts.googleapis.com/css?family=Copse:regular" rel="stylesheet" type="text/css" > <style> h1, h2, h3, h4, h5 { font-family: 'Copse', serif; @@ -54,60 +57,54 @@ </div> <h2>Features</h2> <ul> <li>DRY templates for your api responses</li> +<li>Ships with support for <strong>ActiveRecord</strong> and <strong>Mongoid</strong></li> +<li>Support for Rails 3 Responders</li> +<li>Plays very well together with client libs like <a href="http://documentcloud.github.com/backbone">Backbone.js</a> or <a href="http://restkit.org">RestKit</a> (iOS).</li> <li>Easy but very flexible syntax for defining the templates</li> <li>XML, JSON and JSON-P support out of the box, easy to extend</li> -<li>Support for Rails 3 Responders</li> +<li>Support for meta data like pagination info, etc&hellip;</li> <li>Minimal dependecies (you can also use it without Rails)</li> -<li>Ships with support for <strong>ActiveRecord</strong> and <strong>Mongoid</strong></li> <li>Supports multiple api rendering templates for a models. This is especially useful for API versioning or for example for private vs. public access points to a user’s profile.</li> </ul> + + +<hr /> </td> <td class=code> <div class='highlight'><pre></pre></div> </td> </tr> - <tr id='section-3'> + <tr id='section-Rails_3.x_Quickstart'> <td class=docs> <div class="pilwrap"> - <a class="pilcrow" href="#section-3">&#182;</a> + <a class="pilcrow" href="#section-Rails_3.x_Quickstart">&#182;</a> </div> - <hr /> + <h2>Rails 3.x Quickstart</h2> </td> <td class=code> <div class='highlight'><pre></pre></div> </td> </tr> - <tr id='section-Rails_3.0.x_Quickstart'> + <tr id='section-4'> <td class=docs> <div class="pilwrap"> - <a class="pilcrow" href="#section-Rails_3.0.x_Quickstart">&#182;</a> + <a class="pilcrow" href="#section-4">&#182;</a> </div> - <h2>Rails 3.0.x Quickstart</h2> + <p>Add to gemfile</p> </td> <td class=code> - <div class='highlight'><pre></pre></div> + <div class='highlight'><pre><span class="n">gem</span> <span class="s1">&#39;acts_as_api&#39;</span></pre></div> </td> </tr> <tr id='section-5'> <td class=docs> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> - <p>Add to gemfile</p> - </td> - <td class=code> - <div class='highlight'><pre><span class="n">gem</span> <span class="s1">&#39;acts_as_api&#39;</span></pre></div> - </td> - </tr> - <tr id='section-6'> - <td class=docs> - <div class="pilwrap"> - <a class="pilcrow" href="#section-6">&#182;</a> - </div> <p>Update your bundle</p> </td> <td class=code> <div class='highlight'><pre><span class="n">bundle</span> <span class="n">install</span></pre></div> </td> @@ -121,26 +118,26 @@ </td> <td class=code> <div class='highlight'><pre></pre></div> </td> </tr> - <tr id='section-8'> + <tr id='section-7'> <td class=docs> <div class="pilwrap"> - <a class="pilcrow" href="#section-8">&#182;</a> + <a class="pilcrow" href="#section-7">&#182;</a> </div> <p>Given you have a model <code>User</code>. If you only want to expose the <code>first_name</code> and <code>last_name</code> attribute of a user via your api, you would do something like this:</p> </td> <td class=code> <div class='highlight'><pre></pre></div> </td> </tr> - <tr id='section-9'> + <tr id='section-8'> <td class=docs> <div class="pilwrap"> - <a class="pilcrow" href="#section-9">&#182;</a> + <a class="pilcrow" href="#section-8">&#182;</a> </div> <p>Within your model:</p> <p>First you activate acts_as_api for your model by calling <code>acts_as_api</code>.</p> @@ -157,14 +154,14 @@ <span class="k">end</span> <span class="k">end</span></pre></div> </td> </tr> - <tr id='section-10'> + <tr id='section-9'> <td class=docs> <div class="pilwrap"> - <a class="pilcrow" href="#section-10">&#182;</a> + <a class="pilcrow" href="#section-9">&#182;</a> </div> <p>An API template with the name <code>:name_only</code> was created.</p> <p>See below how to use it in the controller:</p> </td> @@ -181,28 +178,28 @@ </td> <td class=code> <div class='highlight'><pre></pre></div> </td> </tr> - <tr id='section-12'> + <tr id='section-11'> <td class=docs> <div class="pilwrap"> - <a class="pilcrow" href="#section-12">&#182;</a> + <a class="pilcrow" href="#section-11">&#182;</a> </div> <p>Now you just have to exchange the <code>render</code> method in your controller for the <code>render_for_api</code> method.</p> </td> <td class=code> <div class='highlight'><pre><span class="k">class</span> <span class="nc">UsersController</span> <span class="o">&lt;</span> <span class="no">ApplicationController</span> <span class="k">def</span> <span class="nf">index</span> <span class="vi">@users</span> <span class="o">=</span> <span class="no">User</span><span class="o">.</span><span class="n">all</span></pre></div> </td> </tr> - <tr id='section-13'> + <tr id='section-12'> <td class=docs> <div class="pilwrap"> - <a class="pilcrow" href="#section-13">&#182;</a> + <a class="pilcrow" href="#section-12">&#182;</a> </div> <p>Note that it&rsquo;s wise to add a <code>root</code> param when rendering lists.</p> </td> <td class=code> <div class='highlight'><pre> <span class="n">respond_to</span> <span class="k">do</span> <span class="o">|</span><span class="nb">format</span><span class="o">|</span> @@ -232,14 +229,14 @@ </td> <td class=code> <div class='highlight'><pre></pre></div> </td> </tr> - <tr id='section-15'> + <tr id='section-14'> <td class=docs> <div class="pilwrap"> - <a class="pilcrow" href="#section-15">&#182;</a> + <a class="pilcrow" href="#section-14">&#182;</a> </div> <p>Try it. The JSON response of #show should now look like this:</p> <p>Other attributes of the model like <code>created_at</code> or <code>updated_at</code> won’t be included because they were not listed by <code>api_accessible</code> in the model.</p> @@ -251,14 +248,14 @@ <span class="s2">&quot;last_name&quot;</span><span class="p">:</span> <span class="s2">&quot;Doe&quot;</span> <span class="p">}</span> <span class="p">}</span></pre></div> </td> </tr> - <tr id='section-16'> + <tr id='section-15'> <td class=docs> <div class="pilwrap"> - <a class="pilcrow" href="#section-16">&#182;</a> + <a class="pilcrow" href="#section-15">&#182;</a> </div> <hr /> </td> <td class=code> <div class='highlight'><pre></pre></div> @@ -302,13 +299,13 @@ </td> <td class=code> <div class='highlight'><pre></pre></div> </td> </tr> - <tr id='section-19'> + <tr id='section-18'> <td class=docs> <div class="pilwrap"> - <a class="pilcrow" href="#section-19">&#182;</a> + <a class="pilcrow" href="#section-18">&#182;</a> </div> <hr /> </td> <td class=code> <div class='highlight'><pre></pre></div> \ No newline at end of file