Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The best solution I've found to this is not to use the asset pipeline for HTML template files. </p> <p>Instead make a controller called <code>TemplatesController</code> and create only one action. Then map all template URLs to that using a route such as:</p> <pre><code>get /templates/:path.html =&gt; 'templates#page', :constraints =&gt; { :path =&gt; /.+/ } </code></pre> <p>Then move all the template files into <code>app/views/templates</code></p> <p>Then inside the controller, setup the following:</p> <pre><code>caches_page :page def page @path = params[:path] render :template =&gt; 'templates/' + @path, :layout =&gt; nil end </code></pre> <p>This way all of your template files will be served from the controller and then will be cached into public/templates. To avoid cache problems, you can create a timestamp path into the template route so that your cached files are delivered with a version:</p> <pre><code>get '/templates/:timestamp/:path.html' =&gt; 'templates#page', :constraints =&gt; { :path =&gt; /.+/ } </code></pre> <p>This way you can have a new timestamp each time you upload the website and you can store the templates folder anywhere you like. You can even store the templates folder on S3 and have an assets URL for that. Then wherever your template files are addressed, you can use a custom asset method:</p> <pre><code>templateUrl : &lt;%= custom_asset_template_url('some/file.html') %&gt; </code></pre> <p>Where:</p> <pre><code>def custom_asset_template_url(path) "http://custom-asset-server.website.com/templates/#{$some_global_timestamp}/#{path}" end </code></pre> <p>Then just make the asset redirect to the Rails server if it's not found and it will be generated. Or all template files can be pre-generated once uploaded.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload