Skip to content

Instantly share code, notes, and snippets.

# Simply run <%= breadcrumbs(separator, options) %>
def breadcrumbs(separator = ' &gt; ', options = {})
(crumbs, previous) = [], []
request.path.split('/').each do |part|
previous << part
crumbs << link_to(part, previous.join('/'), options)
end
crumbs.join(separator)
end
<%= link_to 'Back', [:admin, @parent, :albums] %>
$ rake paperclip:refresh CLASS=Photo
def delete(name, options = nil)
super
File.delete(real_file_path(name))
rescue SystemCallError => e
# If there's no cache, then there's nothing to complain about
end
ActiveSupport::Cache::FileStore.class_eval do
def delete(name, options = nil)
puts "Real Filename: #{real_file_path(name)}"
super
File.delete(real_file_path(name))
rescue SystemCallError => e
puts "Failed to delete cache. #{e.message}"
end
end
<studio>
<created-at type="datetime">2009-06-18T17:02:49Z</created-at>
<description>A Studio Description Here</description>
<id type="integer">1</id>
<photo-content-type>image/jpeg</photo-content-type>
<photo-file-name>jaws.jpg</photo-file-name>
<photo-file-size type="integer">833900</photo-file-size>
<photo-updated-at type="datetime">2009-06-18T17:02:48Z</photo-updated-at>
<state>active</state>
<title>Some Title Here</title>
def to_xml(options = {}, &block)
thumbs = Proc.new do |opts|
[:large, :thumb, :icon].each do |style|
opts[:builder].tag!("thumbnail-#{style}", self.photo.url(style, false))
end
end
default_options = {
:procs => [thumbs],
:except => [:photo_file_name, :photo_file_size, :photo_content_type, :photo_updated_at]
}
<studio>
<created-at type="datetime">2009-06-18T17:02:49Z</created-at>
<description>A Studio Description Here</description>
<id type="integer">1</id>
<state>active</state>
<title>Some Title Here</title>
<titles-count type="integer">0</titles-count>
<updated-at type="datetime">2009-06-18T17:02:49Z</updated-at>
<url>http://www.google.com</url>
<thumbnail-large>/content/studios/photos/1/large_jaws.jpg</thumbnail-large>