diff --git a/app/controllers/discuss_demos_controller.rb b/app/controllers/discuss_demos_controller.rb index 31b0f1dcc..a0955efe2 100644 --- a/app/controllers/discuss_demos_controller.rb +++ b/app/controllers/discuss_demos_controller.rb @@ -1,5 +1,6 @@ class DiscussDemosController < ApplicationController def index + @discuss_demo_list = DiscussDemo.where("body is not null").order("created_at desc").page(params[:page] || 1).per(10) end @@ -24,7 +25,12 @@ class DiscussDemosController < ApplicationController end def destroy - DiscussDemo.delete_all(["id = ?",params[:id]]) + asset = Kindeditor::Asset.find_by_owner_id(params[:id]) + filepath = File.join(Rails.root,"public","files","uploads", + asset[:created_at].to_s.gsub("+0800","").to_datetime.strftime("%Y%m").to_s, + asset[:asset].to_s) + File.delete(filepath) if File.exist?filepath + DiscussDemo.destroy(params[:id]) redirect_to :controller=> 'discuss_demos',:action => 'index' end diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 949ddd643..f35210f01 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -20,7 +20,7 @@ class WelcomeController < ApplicationController include WelcomeHelper helper :project_score caches_action :robots - before_filter :find_first_page, :only => [:index] + #before_filter :find_first_page, :only => [:index] # before_filter :fake, :only => [:index, :course] before_filter :entry_select, :only => [:index] diff --git a/app/models/discuss_demo.rb b/app/models/discuss_demo.rb index 74b21f9d4..6ed8d15b6 100644 --- a/app/models/discuss_demo.rb +++ b/app/models/discuss_demo.rb @@ -1,4 +1,4 @@ class DiscussDemo < ActiveRecord::Base attr_accessible :title, :body - has_many_kindeditor_assets :attachments, :dependent => :destroy + has_many_kindeditor_assets :assets, :dependent => :destroy end diff --git a/app/views/files/_project_file.html.erb b/app/views/files/_project_file.html.erb index aa597f3f2..b4d849cd6 100644 --- a/app/views/files/_project_file.html.erb +++ b/app/views/files/_project_file.html.erb @@ -1,7 +1,7 @@ <% attachmenttypes = @project.attachmenttypes %> <% sufixtypes = @project.contenttypes %>