Last active
August 29, 2015 14:17
-
-
Save cantonic/51a6b979c9ea2b191256 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alert "yippie" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Drive::FilesController < ApplicationController | |
before_action :authenticate_user! | |
def index | |
load_directory | |
@files = @directory.files | |
end | |
def show | |
@file = Drive::File.find(params[:id]) | |
authorize! :read, @file | |
end | |
def create | |
load_directory | |
@file = @directory.files.build( | |
name: params[:filename], | |
size: params[:filesize], | |
filetype: params[:filetype], | |
url: params[:url], | |
unique_id: params[:unique_id] | |
) | |
authorize! :create, @file | |
@file.save | |
@directory = @directory.to_json | |
@file = @file.to_json | |
end | |
private | |
def load_directory | |
@directory = Drive::Directory.find(params[:directory_id]) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
= render partial: 'page_header', locals: {title: 'Drive', icon:'hdd'} | |
.container | |
.row | |
.col-md-12 | |
%ol.breadcrumb | |
= glyph('folder-open') | |
= render_breadcrumbs :tag => :li, :separator => '' | |
.row | |
.col-md-6 | |
- if can? :create, @new_directory | |
= bootstrap_form_for @new_directory, layout: :inline do |f| | |
= f.hidden_field :parent_id, value: @directory.id | |
= f.text_field :name, placeholder: 'Create Folder', hide_label: true | |
= f.submit('Create') | |
.col-md-6 | |
= s3_uploader_form callback_url: drive_directory_files_path(@directory, format: :js), id: "s3-uploader" do | |
= file_field_tag :file, multiple: true | |
.row | |
.col-md-12 | |
.table-responsive | |
%table.table | |
%thead | |
%tr | |
%th | |
%th Name | |
%th Type | |
%th Created | |
%th Modified | |
%th Size | |
%th | |
%tbody | |
- @directory.children.each do |directory| | |
= render directory | |
- @directory.files.each do |file| | |
= render file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment