毎日1剤Rails良薬のuplload_progress
今日はupload_を使ってみます。progressプラグイン監聴ファイルアップロードstatus及びAJAXアップロードプログレスbar作成
Requirements:
http://sean.treadway.info/articles/2005/07/18/upload-progress-checklist
このプラグインとRequirementsをインストールしたら、私達はcontrollerで使用できます。
参照
*Moved acts_アワタggable,browser_filters、and simplyuhelpful into legacy--all have eigther been deprecated or rolled into Rails core already[DHH]
*Resource feeder turned out to be too restictive and too hard to customize;replace it by atom_feed_helper[DHH]
*Extract dynamic scaffolding plugn from core. #7700[Josh Peek]
*Start a global change for the offical Rails plugins. [Jeremiy Kemper]
Requirements:
http://sean.treadway.info/articles/2005/07/18/upload-progress-checklist
このプラグインとRequirementsをインストールしたら、私達はcontrollerで使用できます。
class DocumentController < ApplicationController
upload_status_for :create
def create
# ... Your document creation action
end
end
class Ducoment2Controller < ApplicationController
upload_status_for :create, :status => :custom_status
def create
# ... Your document creation action
end
def custom_status
# ... Override this action to return content to be replaced in the status container
render :inline => "<%= upload_progress.completed_percent rescue 0 %> % complete", :layout => false
end
end
私たちはviewでこのように使います。
<%= form_tag_with_upload_progress({:action => 'create'}, {
:begin => 'alert("Upload beginning")',
:finish => 'alert("Upload finished")'}) %>
<%= file_field 'document', 'file' %>
<%= submit_tag "Upload" %>
<%= upload_status_tag %>
<%= end_form_tag %>
BTW:Rails公式プラグインはここに紹介されました。Global Changelogを追加して貼ります。参照
*Moved acts_アワタggable,browser_filters、and simplyuhelpful into legacy--all have eigther been deprecated or rolled into Rails core already[DHH]
*Resource feeder turned out to be too restictive and too hard to customize;replace it by atom_feed_helper[DHH]
*Extract dynamic scaffolding plugn from core. #7700[Josh Peek]
*Start a global change for the offical Rails plugins. [Jeremiy Kemper]