What is the best way to serve static HTML documents in Rails with layout? Obviously, I could just store the HTML files in a directory public/, but then I could not apply the layout, or could I? Otherwise, I could put in the config/routes.rbfollowing:
match ':page' => 'static#display', :page => /.+\.html/
Does .+\.htmlit work to end in .html? In any case, assuming this is so, I think I will have a controller:
class StaticController < ApplicationController
layout 'static_files'
def display
render params[:page]
end
end
Assuming this works correctly, will Ruby unnecessarily try to parse the HTML file as an ERB file? Is there a better way for Rails to do this?
source
share