Created by: mariochavez
inline_svg gem is currently broken to work with Sprockets 3 and the Rails application environment set to production. So this has broken administrate as well. Normally a fix should be implemented in broken gem but after looking at why administrate requires inline_svg gem I realize that it is easy to replace it with a helper method.
ApplicationHelper#svg_tag method was added to substitute the work of inline_svg. This method creates a svg tag that will look like:
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"><use
xlink:href="http://localhost:3000/assets/administrate/search-360c782d91a21edd53f5754c3fd8f8984ec5d9b36389f6df1fe618a4e50405b6.svg#search" width="16" height="16"></use></svg>
This will allow to resize the svg image and to use css to change properties like color.
But there are a couple of differences with inline_svg. First the svg file
should have an id property, for my previous example it is search
.
The second difference is that use
tag needs to have height
and width
properties set as attributes of the tag, css properties will not affect the svg
size.
ApplicationHelper#svg_tag used to generate html shown above looks like:
<%= svg_tag "administrate/search.svg",
svg_id: "search", width: "16", height: "16" %>
This solution will play nice with Sprockets and with modern browsers.