1 <?xml version=
"1.0" encoding=
"iso-8859-1"?>
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">
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">
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 );
27 elemStyle = elem.style;
29 if ( elemStyle.display !=
"block" ) {
30 elemStyle.display =
"block"
32 elemStyle.display =
"none"
38 // Make codeblocks hidden by default
39 document.writeln(
"<style type=\"text/css\
">div.method-source-code { display: none }</style>" )
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>
55 <tr class=
"top-aligned-row">
56 <td><strong>In:
</strong></td>
58 <a href=
"../files/app/controllers/songs_controller_rb.html">
59 app/controllers/songs_controller.rb
65 <tr class=
"top-aligned-row">
66 <td><strong>Parent:
</strong></td>
68 <a href=
"ApplicationController.html">
75 <!-- banner header -->
77 <div id=
"bodyContent">
81 <div id=
"contextContent">
83 <div id=
"description">
85 Handles dealing with songs
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.
98 <div id=
"method-list">
99 <h3 class=
"section-bar">Methods
</h3>
101 <div class=
"name-list">
102 <a href=
"#M000030">current_model
</a>
103 <a href=
"#M000029">new
</a>
121 <!-- if method_list -->
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>
134 <div class=
"method-description">
136 Creates a new song and lets you edit it.
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.
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">
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">></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>
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>
168 <div class=
"method-description">
170 Make all songs hang off of the current user
173 This serves two purposes:
176 <li>Makes sure new songs belong to the current user
179 <li>Makes sure the user can
’t access songs that belong to them
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">
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>
203 <div id=
"validator-badges">
204 <p><small><a href=
"http://validator.w3.org/check/referer">[Validate]
</a></small></p>