How to DRY interface / base constants
Let's say I have a constant ANIMALS = %w(dog cat horse)
. What is the ideal way to give it scripts to avoid duplicating it there? One way to do this is to assign it to the global view, like this:
<script>
Constants.animals = <%=raw ANIMALS %>
</script>
but is there a better way to do this?
+3
source to share
1 answer