acts_as_assets 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,3 +1,3 @@
1
1
  = ActsAsAssets
2
2
 
3
- This project rocks and uses MIT-LICENSE.
3
+ This project rocks and uses MIT-LICENSE.
@@ -7,7 +7,7 @@ class ActsAsAssets::AssetsController < ApplicationController
7
7
  before_filter :load_assets, :only => [:index, :destroy]
8
8
 
9
9
  def index
10
- @model = klazz.base_model.find(CGI.unescape(params[klazz.foreign_key_name]))
10
+ @model = assets_base_model
11
11
  respond_to do |format|
12
12
  format.html { render :layout => false }
13
13
  format.json { render :json => @assets }
@@ -15,7 +15,7 @@ class ActsAsAssets::AssetsController < ApplicationController
15
15
  end
16
16
 
17
17
  def create
18
- @model = klazz.base_model.find(CGI.unescape(params[klazz.foreign_key_name]))
18
+ @model = assets_base_model
19
19
  @asset = klazz.create(
20
20
  :asset => params[:file],
21
21
  :asset_content_type => mime_type(params[:file]),
@@ -34,7 +34,7 @@ class ActsAsAssets::AssetsController < ApplicationController
34
34
 
35
35
  def destroy
36
36
  begin
37
- @model = klazz.base_model.find(CGI.unescape(params[klazz.foreign_key_name]))
37
+ @model = assets_base_model
38
38
  @asset = klazz.find_by_id(params[:asset_id])
39
39
  @asset_partial = partial_to_use(@asset)
40
40
  @asset.destroy
@@ -55,15 +55,17 @@ class ActsAsAssets::AssetsController < ApplicationController
55
55
  def get
56
56
  begin
57
57
  @asset = klazz.find(params[:asset_id])
58
-
59
58
  send_file(file_to_download_path, {:filename => File.basename(@asset.asset.path), :content_type => @asset.asset_content_type, :disposition => 'inline'})
60
-
61
59
  rescue ActiveRecord::RecordNotFound
62
60
  respond_with_404
63
61
  end
64
62
  end
65
63
 
66
64
  private
65
+ def assets_base_model
66
+ klazz.base_model.find(CGI.unescape(params[klazz.foreign_key_name]))
67
+ end
68
+
67
69
  def file_to_download_path
68
70
  @path = params[:style].nil? ? @asset.asset.path : @asset.asset.path(params[:style])
69
71
  end
@@ -1,3 +1,3 @@
1
1
  module ActsAsAssets
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
Binary file