Rendering static files
Dynamic webpages
The erb
method is typically used to render dynamic webpages (which should be placed in the app/views
directory):
Static files
However, static files can also be rendered in a similar way to dynamic webpages, using the render_static
method:
Alternatively, the static
method can be used to define a block. The above can be simplified into:
The static
method basically generates a get
route for the specified file path, along with its aliases. Aliases are not required though:
Block definition
If you wish to define multiple static routes at once, you can use the block format:
Storage of static files
Static webpages should be stored in the app/static/public
directory.
If you wish to access the data stored in any JSON
, YAML
or XML
files in this directory (somewhere within your Ruby code), use the Static data accessor Static.public
- read here for more information on how to use the data stored in these files.
Last updated