Class: Dunlop::SourceFilesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- ApplicationController
- Dunlop::SourceFilesController
- Defined in:
- app/controllers/dunlop/source_files_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #download ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #schedule ⇒ Object
- #show ⇒ Object
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'app/controllers/dunlop/source_files_controller.rb', line 24 def create @source_file = SourceFile.factory(source_file_params) redirect_to source_files_path, alert: "No file given" and return unless params[:source_file][:original_file].present? redirect_to source_files_path, alert: "No type specified" and return unless params[:source_file][:sti_type].present? :manage, @source_file @source_file.user = current_user @source_file.save && @source_file.autoload! redirect_to source_files_path end |
#destroy ⇒ Object
34 35 36 37 38 39 |
# File 'app/controllers/dunlop/source_files_controller.rb', line 34 def destroy @source_file = SourceFile.find(params[:id]) :manage, @source_file @source_file.destroy redirect_to source_files_path end |
#download ⇒ Object
41 42 43 44 45 46 |
# File 'app/controllers/dunlop/source_files_controller.rb', line 41 def download @source_file = SourceFile.find(params[:id]) :download, @source_file return redirect_to :back, alert: "File is no longer present" unless @source_file.original_file.present? send_file @source_file.original_file.current_path end |
#index ⇒ Object
4 5 6 7 8 9 10 |
# File 'app/controllers/dunlop/source_files_controller.rb', line 4 def index :index, SourceFile @q = SourceFile.where(sti_type: SourceFile.classes.select{|cls| can? :read, cls}.map(&:name)).search(params[:q]) @q.sorts = "created_at desc" if @q.sorts.empty? @source_files = @q.result.page(params[:page]).per(100) respond_with(@source_files) end |
#new ⇒ Object
18 19 20 21 22 |
# File 'app/controllers/dunlop/source_files_controller.rb', line 18 def new @source_file = SourceFile.new :manage, @source_file respond_with(@source_file) end |
#schedule ⇒ Object
48 49 50 51 52 53 54 |
# File 'app/controllers/dunlop/source_files_controller.rb', line 48 def schedule @source_file = SourceFile.find(params[:id]) :manage, @source_file @source_file.scheduled! flash[:notice] = "Successfully scheduled loading of source file" redirect_to source_files_path end |
#show ⇒ Object
12 13 14 15 16 |
# File 'app/controllers/dunlop/source_files_controller.rb', line 12 def show @source_file = SourceFile.find(params[:id]) :read, @source_file respond_with(@source_file) end |