Class: ActionController::Base
- Defined in:
- lib/six-updater-web/vendor/plugins/active_scaffold/lib/extensions/action_controller_rendering.rb,
lib/six-updater-web/vendor/plugins/active_scaffold/lib/extensions/generic_view_paths.rb,
lib/six-updater-web/vendor/plugins/active_scaffold/lib/bridges/file_column/lib/as_file_column_bridge.rb
Overview
:nodoc:
Direct Known Subclasses
Instance Method Summary collapse
-
#active_scaffold_render_secure_download(file_root) ⇒ Object
In your controller: :options => => true def show active_scaffold_render_secure_download(File.join(RAILS_ROOT, ‘files’)) end In your model: file_column :package, :root_path => File.join(RAILS_ROOT, ‘files’).
- #assign_names_with_active_scaffold ⇒ Object
- #render_with_active_scaffold(*args, &block) ⇒ Object
- #search_generic_view_paths? ⇒ Boolean
Instance Method Details
#active_scaffold_render_secure_download(file_root) ⇒ Object
In your controller:
:options => {:secure_download => true}
def show
active_scaffold_render_secure_download(File.join(RAILS_ROOT, 'files'))
end
In your model:
file_column :package, :root_path => File.join(RAILS_ROOT, 'files')
60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/bridges/file_column/lib/as_file_column_bridge.rb', line 60 def active_scaffold_render_secure_download(file_root) raise if params[:download].nil? # AST Not sure we need to assume encryption responsibility - seems like of authentication is not needed to download the files then the dev can override methods needed to encrypt/decrypt file location on the server. file_path = params[:download]#.decrypt!(:symmetric, :key => active_scaffold_config.secure_download_key) ext = File.extname(file_path).downcase.sub(/^\./, '') case ext when 'pdf' response.headers["Content-Type"] = 'application/pdf' else response.headers["Content-Type"] = "text/#{ext}" end response.headers["Content-disposition:"] = "inline; filename=\"#{params[:download]}\"" render :text => File.read(File.join(file_root, file_path)) end |
#assign_names_with_active_scaffold ⇒ Object
23 24 25 26 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/extensions/generic_view_paths.rb', line 23 def assign_names_with_active_scaffold assign_names_without_active_scaffold @template.view_paths.active_scaffold_paths = self.class.active_scaffold_paths if search_generic_view_paths? end |
#render_with_active_scaffold(*args, &block) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/extensions/action_controller_rendering.rb', line 4 def render_with_active_scaffold(*args, &block) if self.class.uses_active_scaffold? and params[:adapter] and @rendering_adapter.nil? @rendering_adapter = true # recursion control # if we need an adapter, then we render the actual stuff to a string and insert it into the adapter template render :partial => params[:adapter][1..-1], :locals => {:payload => render_to_string(args.first, &block)}, :use_full_path => true, :layout => false @rendering_adapter = nil # recursion control else render_without_active_scaffold(*args, &block) end end |
#search_generic_view_paths? ⇒ Boolean
29 30 31 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/extensions/generic_view_paths.rb', line 29 def search_generic_view_paths? !self.is_a?(ActionMailer::Base) && self.class.action_methods.include?(self.action_name) end |