Class: Member::Depot::FilefoldersController
- Inherits:
-
BaseController
- Object
- BaseController
- Member::Depot::FilefoldersController
- Defined in:
- app/controllers/member/depot/filefolders_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/member/depot/filefolders_controller.rb', line 11 def create @filefolder = current_user.filefolders.new(params[:folder]) @filefolder.user_id = current_user.id @filefolder.state = 'public' respond_to do |wants| if @filefolder.save wants.html do flash[:ok] = "Folder <b>#{@filefolder.title}</b> created successfully" redirect_to member_depot_files_path end else wants.html do redirect_to member_depot_files_path end end end end |
#destroy ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'app/controllers/member/depot/filefolders_controller.rb', line 64 def destroy @folder = current_user.filefolders.find params[:id] @my_files = current_user.files.paginate(:page => params[:page], :order => "created_at DESC", :conditions => ["filefolder_id=?",params[:id]]) if @my_files.empty? @folder.destroy respond_to do |wants| wants.html do flash[:ok]='Folder deleted.' redirect_to member_depot_files_path end end else flash[:error] = 'This folder cannot be deleted, because there are still any files into it.' redirect_to member_depot_filefolder_path end end |
#edit ⇒ Object
32 33 34 |
# File 'app/controllers/member/depot/filefolders_controller.rb', line 32 def edit @filefolder = current_user.filefolders.find(params[:id]) end |
#new ⇒ Object
8 9 |
# File 'app/controllers/member/depot/filefolders_controller.rb', line 8 def new end |
#show ⇒ Object
3 4 5 6 |
# File 'app/controllers/member/depot/filefolders_controller.rb', line 3 def show @filefolder = current_user.filefolders.find(params[:id]) @my_files = current_user.files.paginate(:per_page => 10, :page => params[:page], :order => "created_at DESC", :conditions => ["filefolder_id=?",params[:id]]) end |
#update ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/controllers/member/depot/filefolders_controller.rb', line 36 def update @filefolder = current_user.filefolders.find(params[:id]) @old_state=@filefolder.state @new_state = params[:state] @filefolder.state = params[:state] respond_to do |wants| if @filefolder.update_attributes(params[:filefolder]) wants.html do if @old_state!=@new_state @files = current_user.files.find(:all, :conditions => ["filefolder_id=?",params[:id]]) @files.each {|c| c.update_attribute 'state', params[:state]} flash[:ok] = "Folder <b>#{@filefolder.title}</b> and files into it succcessfully updated!" else flash[:ok] = "Folder <b>#{@filefolder.title}</b> succcessfully updated!" end redirect_to member_depot_files_path end else wants.html do flash.now[:error] = 'Failed to Update a filefolder.' render :action => :edit end end end end |