Created
November 24, 2012 22:35
-
-
Save garethrees/4141674 to your computer and use it in GitHub Desktop.
Rails Shared Templates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%# | |
# Renders Google Analytics tracking script | |
# | |
# Example | |
# | |
# <%= render 'shared/analytics', ua_code: 'UA-XXXXXX-X' %> | |
# | |
#%> | |
<% if Rails.env.production? %> | |
<script type="text/javascript"> | |
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); | |
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); | |
</script> | |
<script type="text/javascript"> | |
try { | |
var pageTracker = _gat._getTracker(<%= ua_code.to_s %>); | |
pageTracker._trackPageview(); | |
} catch(err) {}</script> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%# | |
# Renders form validation messages | |
# | |
# Example | |
# | |
# <%= form_for @mymodel do |f| %> | |
# <%= render 'shared/error_messages', target: @model %> | |
# # ... | |
# <% end %> | |
# | |
#%> | |
<% if target.errors.any? %> | |
<div id="errorExplanation"> | |
<h2><%= pluralize(target.errors.count, 'error') %> prohibited this record from being saved:</h2> | |
<ul> | |
<% target.errors.full_messages.each do |msg| %> | |
<li><%= msg %></li> | |
<% end %> | |
</ul> | |
</div> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%# | |
# Renders flash messages | |
# | |
# Example | |
# | |
# <%= render 'shared/flash', object: flash %> | |
# | |
#%> | |
<% unless flash.blank? -%> | |
<% flash.each do |name, msg| -%> | |
<%= content_tag :div, msg, class: "message message-#{ name }" %> | |
<% end -%> | |
<% end -%> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment