Skip to content

Commit

Permalink
Fixes kirtithorat#1 : Colons in html id attributes with Namespaced Mo…
Browse files Browse the repository at this point in the history
…dels
  • Loading branch information
kirtithorat committed Apr 18, 2014
1 parent 2890fa9 commit 2dc36c8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion carrierwave-crop.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require 'carrierwave/crop/version'
Gem::Specification.new do |spec|
spec.name = "carrierwave-crop"
spec.version = CarrierWave::Crop::VERSION
spec.authors = ["kirtithorat"]
spec.authors = ["Kirti Thorat"]
spec.email = ["[email protected]"]
spec.summary = %q{CarrierWave extension for cropping images with preview.}
spec.description = %q{CarrierWave extension to crop uploaded images using Jcrop plugin.}
Expand Down
7 changes: 4 additions & 3 deletions lib/carrierwave/crop/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ def previewbox(attachment, opts = {})
attachment = attachment.to_sym

if(self.object.send(attachment).class.ancestors.include? CarrierWave::Uploader::Base )
model_name = self.object.class.name.downcase
## Fixes Issue #1 : Colons in html id attributes with Namespaced Models
model_name = self.object.class.name.downcase.split("::").last
width, height = 100, 100
if(opts[:width] && opts[:height])
width, height = opts[:width].round, opts[:height].round
Expand Down Expand Up @@ -52,8 +53,8 @@ def cropbox(attachment, opts={})
attachment_instance = self.object.send(attachment)

if(attachment_instance.class.ancestors.include? CarrierWave::Uploader::Base )

model_name = self.object.class.name.downcase
## Fixes Issue #1 : Colons in html id attributes with Namespaced Models
model_name = self.object.class.name.downcase.split("::").last
hidden_elements = self.hidden_field(:"#{attachment}_crop_x", id: "#{model_name}_#{attachment}_crop_x")
[:crop_y, :crop_w, :crop_h].each do |attribute|
hidden_elements << self.hidden_field(:"#{attachment}_#{attribute}", id: "#{model_name}_#{attachment}_#{attribute}")
Expand Down
2 changes: 1 addition & 1 deletion lib/carrierwave/crop/model_additions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def crop_image(attachment)

module Uploader

# Perfoems cropping.
# Performs cropping.
#
# On original version of attachment
# process crop: :avatar
Expand Down

0 comments on commit 2dc36c8

Please sign in to comment.