root/vendor/file-column-0.3.1/doc/classes/FileColumnHelper.html @ 2

Revision 2, 6.2 kB (checked in by falcon, 17 years ago)

added plugins

  • Property svn:executable set to *
RevLine 
[2]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">
5
6<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7<head>
8  <title>Module: FileColumnHelper</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[
14
15  function popupCode( url ) {
16    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17  }
18
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;
26
27    elemStyle = elem.style;
28   
29    if ( elemStyle.display != "block" ) {
30      elemStyle.display = "block"
31    } else {
32      elemStyle.display = "none"
33    }
34
35    return true;
36  }
37 
38  // Make codeblocks hidden by default
39  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40 
41  // ]]>
42  </script>
43
44</head>
45<body>
46
47
48
49    <div id="classHeader">
50        <table class="header-table">
51        <tr class="top-aligned-row">
52          <td><strong>Module</strong></td>
53          <td class="class-name-in-header">FileColumnHelper</td>
54        </tr>
55        <tr class="top-aligned-row">
56            <td><strong>In:</strong></td>
57            <td>
58                <a href="../files/lib/file_column_helper_rb.html">
59                lib/file_column_helper.rb
60                </a>
61        <br />
62            </td>
63        </tr>
64
65        </table>
66    </div>
67  <!-- banner header -->
68
69  <div id="bodyContent">
70
71
72
73  <div id="contextContent">
74
75    <div id="description">
76      <p>
77This module contains helper methods for displaying and uploading files for
78attributes created by <tt>FileColumn</tt>&#8217;s <tt>file_column</tt>
79method. It will be automatically included into ActionView::Base, thereby
80making this module&#8217;s methods available in all your views.
81</p>
82
83    </div>
84
85
86   </div>
87
88    <div id="method-list">
89      <h3 class="section-bar">Methods</h3>
90
91      <div class="name-list">
92      <a href="#M000001">file_column_field</a>&nbsp;&nbsp;
93      <a href="#M000002">url_for_file_column</a>&nbsp;&nbsp;
94      </div>
95    </div>
96
97  </div>
98
99
100    <!-- if includes -->
101
102    <div id="section">
103
104
105
106
107
108     
109
110
111    <!-- if method_list -->
112    <div id="methods">
113      <h3 class="section-bar">Public Instance methods</h3>
114
115      <div id="method-M000001" class="method-detail">
116        <a name="M000001"></a>
117
118        <div class="method-heading">
119          <a href="FileColumnHelper.src/M000001.html" target="Code" class="method-signature"
120            onclick="popupCode('FileColumnHelper.src/M000001.html');return false;">
121          <span class="method-name">file_column_field</span><span class="method-args">(object, method, options={})</span>
122          </a>
123        </div>
124     
125        <div class="method-description">
126          <p>
127Use this helper to create an upload field for a file_column attribute. This
128will generate an additional hidden field to keep uploaded files during
129form-redisplays. For example, when called with
130</p>
131<pre>
132  &lt;%= file_column_field(&quot;entry&quot;, &quot;image&quot;) %&gt;
133</pre>
134<p>
135the following HTML will be generated (assuming the form is redisplayed and
136something has already been uploaded):
137</p>
138<pre>
139  &lt;input type=&quot;hidden&quot; name=&quot;entry[image_temp]&quot; value=&quot;...&quot; /&gt;
140  &lt;input type=&quot;file&quot; name=&quot;entry[image]&quot; /&gt;
141</pre>
142<p>
143You can use the <tt>option</tt> argument to pass additional options to the
144file-field tag.
145</p>
146<p>
147Be sure to set the enclosing form&#8217;s encoding to
148&#8216;multipart/form-data&#8217;, by using something like this:
149</p>
150<pre>
151   &lt;%= form_tag {:action =&gt; &quot;create&quot;, ...}, :multipart =&gt; true %&gt;
152</pre>
153        </div>
154      </div>
155
156      <div id="method-M000002" class="method-detail">
157        <a name="M000002"></a>
158
159        <div class="method-heading">
160          <a href="FileColumnHelper.src/M000002.html" target="Code" class="method-signature"
161            onclick="popupCode('FileColumnHelper.src/M000002.html');return false;">
162          <span class="method-name">url_for_file_column</span><span class="method-args">(object_name, method, suffix=nil)</span>
163          </a>
164        </div>
165     
166        <div class="method-description">
167          <p>
168Creates an URL where an uploaded file can be accessed. When called for an
169Entry object with id 42 (stored in <tt>@entry</tt>) like this
170</p>
171<pre>
172  &lt;%= url_for_file_column(&quot;entry&quot;, &quot;image&quot;)
173</pre>
174<p>
175the following URL will be produced, assuming the file &quot;test.png&quot;
176has been stored in the &quot;image&quot;-column of an Entry object stored
177in <tt>@entry</tt>:
178</p>
179<pre>
180 /entry/image/42/test.png
181</pre>
182<p>
183This will produce a valid URL even for temporary uploaded files, e.g. files
184where the object they are belonging to has not been saved in the database
185yet.
186</p>
187<p>
188If there is currently no uploaded file stored in the object&#8217;s column
189this method will return <tt>nil</tt>.
190</p>
191<p>
192If the optional <tt>suffix</tt> parameter is given, it will be inserted
193into the filename before the extension. So if the uploaded file is name
194&quot;vancouver.jpg&quot; and you have the following code in your view
195</p>
196<pre>
197   &lt;%= url_for_file_column(&quot;entry&quot;, &quot;image&quot;, &quot;thumb&quot;) %&gt;
198</pre>
199<p>
200the resulting URL&#8217;s would point to a file
201&quot;vancouver-thumb.jpg&quot;. This can be used to access different
202versions of a file as produced by <a
203href="FileColumn/Magick.html">FileColumn::Magick</a>, for example.
204</p>
205<p>
206Note that the object has to be stored in an instance variable. So if
207<tt>object_name</tt> is &quot;entry&quot; your object has to be stored in
208<tt>@entry</tt>.
209</p>
210        </div>
211      </div>
212
213
214    </div>
215
216
217  </div>
218
219
220<div id="validator-badges">
221  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
222</div>
223
224</body>
225</html>
Note: See TracBrowser for help on using the browser.