Created
February 16, 2010 17:38
-
-
Save maurcs/305720 to your computer and use it in GitHub Desktop.
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
no such file to load -- grip/url_helper |
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
# lib/grip-rails.rb | |
require 'rubygems' | |
require 'mongo_mapper' | |
require 'grip' | |
require 'mongo/gridfs' | |
require 'mime/types' | |
require 'tempfile' | |
require 'grip/url_helper' | |
require 'grip/rails/image' |
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
# lib/grip/url_helper.rb | |
module Grip | |
module UrlHelper | |
def url(variant = nil) | |
case | |
when self.file_name =~ /png|jpg|gif|jpeg/ | |
if variant && variants[variant.to_sym] | |
width = variants[variant.to_sym][:width] | |
height = variants[variant.to_sym][:height] | |
"/images/grid/resize_#{width}_#{height}_#{grid_key}" | |
else | |
"/images/grid/#{grid_key}" | |
end | |
else | |
grid_key | |
end | |
end | |
end | |
end | |
Grip::Attachment.send(:include, Grip::UrlHelper) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment