Module: UploadColumn::UploadColumnHelper
- Defined in:
- lib/upload_column/rails/upload_column_helper.rb
Instance Method Summary collapse
-
#upload_column_field(object, method, options = {}) ⇒ Object
Returns an input tag of the “file” type tailored for accessing an upload_column field (identified by method) on an object assigned to the template (identified by object).
-
#upload_form_for(*args, &block) ⇒ Object
A helper method for creating a form tag to use with uploadng files, it works exactly like Rails’ form_for, except that :multipart is always true.
-
#upload_form_tag(url_for_options = {}, options = {}, *parameters_for_url, &proc) ⇒ Object
A helper method for creating a form tag to use with uploadng files, it works exactly like Rails’ form_tag, except that :multipart is always true.
Instance Method Details
#upload_column_field(object, method, options = {}) ⇒ Object
Returns an input tag of the “file” type tailored for accessing an upload_column field (identified by method) on an object assigned to the template (identified by object). Additional options on the input tag can be passed as a hash with options.
Example (call, result)
upload_column_field( :user, :picture )
<input id="user_picture_temp" name="user[picture_temp]" type="hidden" />
<input id="user_picture" name="user[picture]" size="30" type="file" />
Note: if you use file_field instead of upload_column_field, the file will not be stored across form redisplays.
14 15 16 |
# File 'lib/upload_column/rails/upload_column_helper.rb', line 14 def upload_column_field(object, method, ={}) file_field(object, method, ) + hidden_field(object, method.to_s + '_temp') end |
#upload_form_for(*args, &block) ⇒ Object
A helper method for creating a form tag to use with uploadng files, it works exactly like Rails’ form_for, except that :multipart is always true
27 28 29 30 31 32 33 34 |
# File 'lib/upload_column/rails/upload_column_helper.rb', line 27 def upload_form_for(*args, &block) = args. [:html] ||= {} [:html][:multipart] = true args.push() form_for(*args, &block) end |
#upload_form_tag(url_for_options = {}, options = {}, *parameters_for_url, &proc) ⇒ Object
A helper method for creating a form tag to use with uploadng files, it works exactly like Rails’ form_tag, except that :multipart is always true
20 21 22 23 |
# File 'lib/upload_column/rails/upload_column_helper.rb', line 20 def upload_form_tag( = {}, = {}, *parameters_for_url, &proc) [:multipart] = true form_tag( , , *parameters_for_url, &proc ) end |