Add upload of Terms of Service files

Admins can upload files and view the most recent (current) one.
This commit is contained in:
Maikel Linke
2021-04-22 13:41:42 +10:00
parent ed4f61acd7
commit abe76ccf0f
4 changed files with 38 additions and 1 deletions

View File

@@ -3,6 +3,25 @@
module Admin
class TermsOfServiceFilesController < Spree::Admin::BaseController
def show
@current_file = TermsOfServiceFile.current
@new_file = TermsOfServiceFile.new
end
def create
TermsOfServiceFile.create!(file_params)
redirect_to main_app.admin_terms_of_service_files_path
end
private
# Needed by Spree::Admin::BaseController#authorize_admin or it
# tries to find a Spree model.
def model_class
TermsOfServiceFile
end
def file_params
params.require(:terms_of_service_file).permit(:attachment)
end
end
end