Skip to content

Instantly share code, notes, and snippets.

@maurcs
Created February 16, 2010 17:38
Show Gist options
  • Save maurcs/305720 to your computer and use it in GitHub Desktop.
Save maurcs/305720 to your computer and use it in GitHub Desktop.
no such file to load -- grip/url_helper
# 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'
# 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