Files
openfoodnetwork/app/controllers/admin/terms_of_service_files_controller.rb
Maikel Linke abe76ccf0f Add upload of Terms of Service files
Admins can upload files and view the most recent (current) one.
2021-06-09 14:06:54 +10:00

28 lines
628 B
Ruby

# frozen_string_literal: true
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