Skip to content

Instantly share code, notes, and snippets.

@teaforthecat
Last active December 13, 2015 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save teaforthecat/4945831 to your computer and use it in GitHub Desktop.
Save teaforthecat/4945831 to your computer and use it in GitHub Desktop.
# wraps third..+ paragraphs in div.more_content
# first two paragraphs are left in tack
def read_more_content html
first, second, *rest = Nokogiri::HTML::fragment(html).children
out = first.to_s + second.to_s
if rest.present?
out << "\n\n<div class=\"more_content\">"
out << rest.map(&:to_s).reduce(:+)
out << "</div>"
end
out
end
def bip object, attr, args={}
path = admin_bip_path(object, model: object.class.to_s.parameterize)
best_in_place object, attr, args.merge(path: path)
end
def pjax_section_link resource, section, classes=nil
link_to(section.humanize.upcase,
send("#{resource.class.to_s.downcase}_section_path", resource,
section: section),
class: "pjax #{classes}")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment