Skip to content

Instantly share code, notes, and snippets.

View nazarhussain's full-sized avatar
🎯
Focusing

Nazar Hussain nazarhussain

🎯
Focusing
View GitHub Profile
@nazarhussain
nazarhussain / Readme
Created June 22, 2011 13:29
Enable conditional default_url for Paperclip, to set default url with some method in the model
In some cases you need to set the default_url of paper clip base on some condition. e.g. You want to set default image on basis of gender of user. For this purpose this gist can make it possible to use a method as default_url. Just copy paper_clip_default_url_fix.rb to initializers folder, and use default_url as mentioned in model.rb
module DataListHelper
def list_headers(args=[])
args = Array.new(args)
columns = []
args.map { |o| columns << content_tag(:li, o.split(":").first, :style=>"width:#{o.split(":").second}px;") }
content_tag(:ul, columns.join(" ").html_safe, :class=>"list-headers")
end
def data_list_for(object, headers=[], &block)
if object.is_a? Array