Skip to content

Instantly share code, notes, and snippets.

@tsmsogn
Last active December 14, 2015 21:28
Show Gist options
  • Select an option

  • Save tsmsogn/5151246 to your computer and use it in GitHub Desktop.

Select an option

Save tsmsogn/5151246 to your computer and use it in GitHub Desktop.
[rails]Snippets
<% if object.errors.any? %>
<div id="error_explanation">
<div class="alert alert-error">
The form contains <%= pluralize(object.errors.count, "error") %>.
</div>
<ul>
<% object.errors.full_messages.each do |msg| %>
<li>* <%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
module ApplicationHelper
# Returns the ful title on a per-page basis.
def full_title(page_title)
base_title = "Ruby on Rails Tutorial Sample App"
if page_title.empty?
base_title
else
"#{base_title} | #{page_title}"
end
end
end
<% flash.each do |key, value| %>
<%= content_tag(:div, value, class: "alert alert-#{key}") %>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment