Class: Concen::GridFilesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Concen::GridFilesController
- Defined in:
- app/controllers/concen/grid_files_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/controllers/concen/grid_files_controller.rb', line 10 def create @page = Page.find(params[:page_id]) @grid_file = @page.grid_files.build filename = params[:filename] if ["css", "js"].include?(params[:file_type]) unless MIME::Types.type_for(filename).first.to_s.include?(params[:file_type]) filename << "." + params[:file_type] end end if @grid_file.store("", filename) content = render_to_string(:partial => "concen/pages/files") render :json => {:success => true, :content => content} else render :json => {:success => false} end end |
#destroy ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/controllers/concen/grid_files_controller.rb', line 42 def destroy @page = Page.find(params[:page_id]) @grid_file = @page.grid_files.find(params[:id]) respond_to do |format| if @grid_file.destroy format.html { redirect_to edit_concen_page_path(@page) } format.json { render :json => {:success => true} } else format.html { redirect_to edit_concen_page_path(@page) } format.json { render :json => {:success => false} } end end end |
#edit ⇒ Object
27 28 29 30 |
# File 'app/controllers/concen/grid_files_controller.rb', line 27 def edit @page = Page.find(params[:page_id]) @grid_file = @page.grid_files.find(params[:id]) end |
#new ⇒ Object
5 6 7 8 |
# File 'app/controllers/concen/grid_files_controller.rb', line 5 def new @page = Page.find(params[:page_id]) @grid_file = @page.grid_files.build end |
#update ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'app/controllers/concen/grid_files_controller.rb', line 32 def update @page = Page.find(params[:page_id]) @grid_file = @page.grid_files.find(params[:id]) if @grid_file.store(params[:concen_grid_file_page], @grid_file.original_filename) redirect_to edit_concen_page_grid_file_path(@page, @grid_file) else render :edit end end |
#upload ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'app/controllers/concen/grid_files_controller.rb', line 56 def upload # logger.info { "----#{env['rack.input']}" } # logger.info { "----#{env['HTTP_X_FILE_NAME']}" } # logger.info { "----#{env['CONTENT_TYPE']}" } @page = Page.find(params[:page_id]) @grid_file = @page.grid_files.build if env["rack.input"] file = env["rack.input"] filename = CGI::unescape(env["HTTP_X_FILE_NAME"]) else file = params[:qqfile].read filename = params[:qqfile].original_filename end if @grid_file.store(file, filename) content = render_to_string(:partial => "concen/pages/files") render :json => {:success => true, :content => content} end end |