Class: ActiveHashcash::AssetsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/active_hashcash/assets_controller.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#showObject



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/active_hashcash/assets_controller.rb', line 7

def show
  if endpoints.include?(file_name = File.basename(request.path))
    file_path = ActiveHashcash::Engine.root.join / "app/views/active_hashcash/assets" / file_name
    if File.exist?("#{file_path}.erb")
      render(params[:id], mime_type: mime_type)
    else
      render(file: file_path)
    end
    expires_in(1.day, public: true)
  else
    raise ActionController::RoutingError.new
  end
end