rails_amp icon indicating copy to clipboard operation
rails_amp copied to clipboard

cloudinary gem & rails_amp

Open giugrilli opened this issue 6 years ago • 3 comments

if using this gem with cloudinary gem, the cloudinary helper:

cl_image_tag (which is a wrapper to image_tag, used to create img tags with cloudinary parameters)

creates an infinite loop which throws:

SystemStackError (stack level too deep)

giugrilli avatar Aug 14 '17 19:08 giugrilli

Thank you for your report. Can you show me the error messages or logs?

takafumir avatar Aug 30 '17 10:08 takafumir

@takafumir - I'm getting the same error and also have the cloudinary gem. I have just installed your gem and was testing it on a single object type and got this error. I tried removing all object types from the rails_amp.yml, but I still get this error on every page where I use the cloudinary helper cl_image_tag (as noted above.)

Here's the on-page error:

SystemStackError at /learning_resources/learn-american-sign-language
stack level too deep

Application Frames All Frames
unsigned_download_url
cloudinary (1.8.2) lib/cloudinary/utils.rb, line 340
cloudinary_url
cloudinary (1.8.2) lib/cloudinary/utils.rb, line 612
cloudinary_url_internal
cloudinary (1.8.2) lib/cloudinary/helper.rb, line 296
cloudinary_tag
cloudinary (1.8.2) lib/cloudinary/helper.rb, line 46
cl_image_tag
cloudinary (1.8.2) lib/cloudinary/helper.rb, line 30
image_tag_with_cloudinary
cloudinary (1.8.2) lib/cloudinary/helper.rb, line 82
image_tag
rails_amp (0.2.2) lib/rails_amp/view_helpers/image_tag_helper.rb, line 40
block in cl_image_tag
cloudinary (1.8.2) lib/cloudinary/helper.rb, line 32
cloudinary_tag
cloudinary (1.8.2) lib/cloudinary/helper.rb, line 62
cl_image_tag
cloudinary (1.8.2) lib/cloudinary/helper.rb, line 30
image_tag_with_cloudinary
cloudinary (1.8.2) lib/cloudinary/helper.rb, line 82

And the log (partial):

Rendered learning_resources/show.html.erb within layouts/application (586.8ms)
SystemStackError (stack level too deep)

SystemStackError - stack level too deep:
  app/views/learning_resources/_resource_thumbnails.html.erb:6:in `_app_views_learning_resources__resource_thumbnails_html_erb__1570303902673928730_70256559926940'
  app/views/learning_resources/show.html.erb:326:in `_app_views_learning_resources_show_html_erb___535625416886347383_70256531079900'
  lib/middleware/turbo_dev.rb:33:in `call'

    1 rows, 2 bytes
    lib/middleware/turbo_dev.rb:33:in `call'
    31 rows, 1244 bytes
    lib/middleware/turbo_dev.rb:33:in `call'
  User Load (0.5ms)  SELECT  "users".* FROM "users" WHERE "users"."id" = $1  ORDER BY "users"."id" ASC LIMIT 1  [["id", 5]]
    1 rows, 511 bytes
    lib/middleware/turbo_dev.rb:33:in `call'
Started GET "/"
Processing by StaticPagesController#home as HTML
  GradeLevel Load (0.4ms)  SELECT "grade_levels".* FROM "grade_levels"  ORDER BY "grade_levels"."ordinal" ASC
    13 rows, 355 bytes
    app/views/static_pages/home.html.erb:28:in `_app_views_static_pages_home_html_erb___3150801494014486130_70256546922560'
    app/controllers/static_pages_controller.rb:16:in `home'
    lib/middleware/turbo_dev.rb:33:in `call'
    5 rows, 162 bytes
    app/views/static_pages/home.html.erb:28:in `_app_views_static_pages_home_html_erb___3150801494014486130_70256546922560'
    app/controllers/static_pages_controller.rb:16:in `home'
    lib/middleware/turbo_dev.rb:33:in `call'
    1 rows, 2 bytes
    app/views/static_pages/home.html.erb:28:in `_app_views_static_pages_home_html_erb___3150801494014486130_70256546922560'
    app/controllers/static_pages_controller.rb:16:in `home'
    lib/middleware/turbo_dev.rb:33:in `call'
  Rendered static_pages/home.html.erb within layouts/application (278.0ms)
SystemStackError (stack level too deep)

SystemStackError - stack level too deep:
  app/views/static_pages/home.html.erb:99:in `_app_views_static_pages_home_html_erb___3150801494014486130_70256546922560'
  app/controllers/static_pages_controller.rb:16:in `home'
  lib/middleware/turbo_dev.rb:33:in `call'

Hope this helps - let me know if I can provide more detail.

wemmick avatar Mar 11 '18 00:03 wemmick

Fyi, Cloudinary offered a workaround that appears to have cleared up the issue for me:

set enhance_image_tag: false in your Cloudinary configuration (either in your coudinary.yml file or through Cloudinary.config) This will make sure that the original ActionView::Base#image_tag won't be replaced by Cloudinary's causing a loop of calls: cl_image_tag => image_tag_without_cloudinary => image_tag => RailsAmp#image_tag => super =>cl_image_tag

wemmick avatar Mar 19 '18 04:03 wemmick