ruby on rails - stack level too deep when uploading and resizing image using carrierwave and rmagick -
when commenting line "process :resize_to_fit => [200, 300]" in imageuploader class code working fine want resize image when uploading.
please help.
log:
started patch "/products/980190968" 127.0.0.1 @ 2014-06-03 11:35:08 +0530 processing productscontroller#update html parameters: {"utf8"=>"✓", "authenticity_token"=>"d//km/eexmdwt7wtmsqpswnedgampzgz7i7hembuc3s=", "product"=>{"title"=>"with no image", "description"=>"asdasdasdasdasdasdasdsadasdasdasda", "image_url"=>#<actiondispatch::http::uploadedfile:0x2e936b0 @tempfile=#<tempfile:c:/users/ahmad/appdata/local/temp/rackmultipart20140603-1836-1098spu>, @original_filename="cs.jpg", @content_type="image/jpeg", @headers="content-disposition: form-data; name=\"product[image_url]\"; filename=\"cs.jpg\"\r\ncontent-type: image/jpeg\r\n">, "price"=>"39.90"}, "commit"=>"update product", "id"=>"980190968"} user load (0.0ms) select "users".* "users" "users"."id" = 4 limit 1 product load (1.0ms) select "products".* "products" "products"."id" = $1 limit 1 [["id", 980190968]] cart load (1.0ms) select "carts".* "carts" "carts"."id" = $1 limit 1 [["id", 76]] (0.0ms) begin (1.0ms) rollback completed 500 internal server error in 108ms systemstackerror (stack level deep): actionpack (4.1.1) lib/action_dispatch/middleware/reloader.rb:79 rendered c:/ruby200/lib/ruby/gems/2.0.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/templates/rescues/_source.erb (2.0ms) rendered c:/ruby200/lib/ruby/gems/2.0.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (2.0ms) rendered c:/ruby200/lib/ruby/gems/2.0.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (2.0ms) rendered c:/ruby200/lib/ruby/gems/2.0.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (118.0ms)
here imageuploader class:
class imageuploader < carrierwave::uploader::base # include rmagick or minimagick support: include carrierwave::rmagick # include carrierwave::minimagick # choose kind of storage use uploader: storage :file # storage :fog # sensible default uploaders meant mounted: def store_dir "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" end def default_url "/images/defaults/notavailable.jpg" end # process files uploaded: #process :resize_to_fit => [200, 300] # images might use this: def extension_white_list %w(jpg jpeg gif png) end end
and product model:
class product < activerecord::base has_many :line_items has_many :orders, through: :line_items #has_and_belongs_to_many :categories before_destroy :ensure_not_referenced_by_any_line_item validates :title, :description, presence: true validates :price, numericality: {greater_than_or_equal_to: 0.01} validates :title, uniqueness: true validates :image_url, allow_blank: true, format: { with: %r{\.(gif|jpg|png)\z}i, message: 'must url gif, jpg or png image.' } validates :title, length: {minimum: 10} mount_uploader :image_url, imageuploader def self.latest product.order(:updated_at).last end private # ensure there no line items referencing product def ensure_not_referenced_by_any_line_item if line_items.empty? return true else errors.add(:base, 'line items present') return false end end end
i had similar problem. fix it, in gemfile this:
gem 'rmagick', require: false
instead of this:
gem 'rmagick'
restart server , try again.
Comments
Post a Comment