diff --git a/app/controllers/admin/patchfiles_controller.rb b/app/controllers/admin/patchfiles_controller.rb index 900c9d2..2091a51 100644 --- a/app/controllers/admin/patchfiles_controller.rb +++ b/app/controllers/admin/patchfiles_controller.rb @@ -21,7 +21,13 @@ class Admin::PatchfilesController < OrbitAdminController end def edit params["filefield"]["file_show"].each do |name,status| - @file_to_show.file_show[name][:status] = status.to_i + @file_to_show.file_show[name][:status] = status.to_i rescue nil + end + if params["filefield"]["refresh_btn"] == "true" + @default_field = Filefield.new() + @file_to_show.file_show = @default_field.file_show + @file_to_show.save + redirect_to admin_patchfiles_path and return end params["filefield"]["sub_file_fields"].each do |name,files| files.each do |index,file_and_status| diff --git a/app/models/filefield.rb b/app/models/filefield.rb index fabdfbd..860d5d7 100644 --- a/app/models/filefield.rb +++ b/app/models/filefield.rb @@ -74,6 +74,9 @@ class Filefield FileUtils.cd('..') @back_foler = file_name.dup #very important,don't just use '=',it will change original value when it change @back_foler[-1] = "_back/." + if !Dir.exist?(file_name) + FileUtils.mkdir_p file_name + end FileUtils.cp_r(@back_foler, file_name) end end @@ -82,6 +85,9 @@ class Filefield if (file_name.include? "/") == false FileUtils.cp(file_name , dest_file_path) else + if !Dir.exist?(dest_file_path) + FileUtils.mkdir_p dest_file_path + end FileUtils.cp_r(file_name , dest_file_path+'..') end end diff --git a/app/views/admin/patchfiles/index.html.erb b/app/views/admin/patchfiles/index.html.erb index d9e9289..ba06d45 100644 --- a/app/views/admin/patchfiles/index.html.erb +++ b/app/views/admin/patchfiles/index.html.erb @@ -39,8 +39,10 @@ <%end%> <%=file.submit "#{t(:updatefont)}",{:id=>"updatebtn",:onclick=>"return updatefcn()"}%> <%=file.text_field :recovery_btn, {:id=>"hidden-recovery",:type => "hidden",:value=>"false"} %> + <%=file.text_field :refresh_btn, {:id=>"hidden-refresh",:type => "hidden",:value=>"false"} %> + <%end%> 網站目錄根路徑:<%=Dir.pwd.to_s%>
  • @@ -217,4 +219,7 @@ }); return false; }; + function destroy_mongofield_fcn(){ + $('#hidden-refresh').val('true'); + }; \ No newline at end of file