script tag when rendered as HTML.
The script tag will be output exactly where you put it in the view.
Libraries like jQuery, which are included at the bottom of the layout in the application manifest, aren't defined yet. Your inline script can't use them, which may be undesirable. To output the script tag below the application manifest, use
yield, as described in the Layouts & Rendering Rails guide. The example below combines
No matter where you include that in the view, the rendered
script element will be output at the bottom of the page, underneath the application manifest, providing access to all the scripts it contains.
.html_safe on the string to escape it, and wraps the string with an HTML script tag before outputting it into the layout at the location of
Partials from Plugins
The last technique I'll mention is
append_partials, which each Workarea layout calls twice—once in the head and once in the body.
The Google Analytics plugin, for example, uses the head append point to insert a view which includes nothing but the Google Analytics embed code.
How'd We Do?
If you found this article was missing information or wasn't quite what you were looking for, we are open to any suggestions or feedback on what we could do better.Help Us Out