Adding some documentation.
[lyrix.git] / doc / app / classes / SongsController.html
blob5e7a7086fb93a519f0d370657817c167bc8ac63e
1 <?xml version="1.0" encoding="iso-8859-1"?>
2 <!DOCTYPE html
3 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
6 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7 <head>
8 <title>Class: SongsController</title>
9 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10 <meta http-equiv="Content-Script-Type" content="text/javascript" />
11 <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12 <script type="text/javascript">
13 // <![CDATA[
15 function popupCode( url ) {
16 window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
19 function toggleCode( id ) {
20 if ( document.getElementById )
21 elem = document.getElementById( id );
22 else if ( document.all )
23 elem = eval( "document.all." + id );
24 else
25 return false;
27 elemStyle = elem.style;
29 if ( elemStyle.display != "block" ) {
30 elemStyle.display = "block"
31 } else {
32 elemStyle.display = "none"
35 return true;
38 // Make codeblocks hidden by default
39 document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
41 // ]]>
42 </script>
44 </head>
45 <body>
49 <div id="classHeader">
50 <table class="header-table">
51 <tr class="top-aligned-row">
52 <td><strong>Class</strong></td>
53 <td class="class-name-in-header">SongsController</td>
54 </tr>
55 <tr class="top-aligned-row">
56 <td><strong>In:</strong></td>
57 <td>
58 <a href="../files/app/controllers/songs_controller_rb.html">
59 app/controllers/songs_controller.rb
60 </a>
61 <br />
62 </td>
63 </tr>
65 <tr class="top-aligned-row">
66 <td><strong>Parent:</strong></td>
67 <td>
68 <a href="ApplicationController.html">
69 ApplicationController
70 </a>
71 </td>
72 </tr>
73 </table>
74 </div>
75 <!-- banner header -->
77 <div id="bodyContent">
81 <div id="contextContent">
83 <div id="description">
84 <p>
85 Handles dealing with songs
86 </p>
87 <p>
88 We use make_resourceful to create most of the RESTful actions of the
89 controller. We use a custom new action because it behaves a little
90 different, but otherwise the actions are generated by make_resourceful.
91 </p>
93 </div>
96 </div>
98 <div id="method-list">
99 <h3 class="section-bar">Methods</h3>
101 <div class="name-list">
102 <a href="#M000030">current_model</a>&nbsp;&nbsp;
103 <a href="#M000029">new</a>&nbsp;&nbsp;
104 </div>
105 </div>
107 </div>
110 <!-- if includes -->
112 <div id="section">
121 <!-- if method_list -->
122 <div id="methods">
123 <h3 class="section-bar">Public Instance methods</h3>
125 <div id="method-M000029" class="method-detail">
126 <a name="M000029"></a>
128 <div class="method-heading">
129 <a href="#M000029" class="method-signature">
130 <span class="method-name">new</span><span class="method-args">()</span>
131 </a>
132 </div>
134 <div class="method-description">
136 Creates a new song and lets you edit it.
137 </p>
139 Instead of just showing a blank form, we create a new song in the database
140 first. This lets us use the same in-place editors and forms for both views.
141 Also helps maintain sidebar consistency.
142 </p>
143 <p><a class="source-toggle" href="#"
144 onclick="toggleCode('M000029-source');return false;">[Source]</a></p>
145 <div class="method-source-code" id="M000029-source">
146 <pre>
147 <span class="ruby-comment cmt"># File app/controllers/songs_controller.rb, line 37</span>
148 37: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">new</span>
149 38: <span class="ruby-ivar">@song</span> = <span class="ruby-identifier">current_model</span>.<span class="ruby-identifier">create</span>(<span class="ruby-identifier">:title</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'Untitled'</span>)
150 39: <span class="ruby-identifier">redirect_to</span> <span class="ruby-identifier">edit_song_path</span>(<span class="ruby-ivar">@song</span>)
151 40: <span class="ruby-keyword kw">end</span>
152 </pre>
153 </div>
154 </div>
155 </div>
157 <h3 class="section-bar">Protected Instance methods</h3>
159 <div id="method-M000030" class="method-detail">
160 <a name="M000030"></a>
162 <div class="method-heading">
163 <a href="#M000030" class="method-signature">
164 <span class="method-name">current_model</span><span class="method-args">()</span>
165 </a>
166 </div>
168 <div class="method-description">
170 Make all songs hang off of the current user
171 </p>
173 This serves two purposes:
174 </p>
175 <ul>
176 <li>Makes sure new songs belong to the current user
178 </li>
179 <li>Makes sure the user can&#8217;t access songs that belong to them
181 </li>
182 </ul>
183 <p><a class="source-toggle" href="#"
184 onclick="toggleCode('M000030-source');return false;">[Source]</a></p>
185 <div class="method-source-code" id="M000030-source">
186 <pre>
187 <span class="ruby-comment cmt"># File app/controllers/songs_controller.rb, line 49</span>
188 49: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">current_model</span>
189 50: <span class="ruby-identifier">current_user</span>.<span class="ruby-identifier">songs</span>
190 51: <span class="ruby-keyword kw">end</span>
191 </pre>
192 </div>
193 </div>
194 </div>
197 </div>
200 </div>
203 <div id="validator-badges">
204 <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
205 </div>
207 </body>
208 </html>