(Rails 5) cl_image_tag error

Comments

10 comments

  • Avatar
    Roee Ben Ari

    Hi Laure,

    'cl_image_tag' is part of `CloudinaryHelper` module, which needs to be included in your project. 

    If it is included and you still see the issue, it would be great if you could share more details (feel free to open a support if you want to keep the data private).

    0
    Comment actions Permalink
  • Avatar
    Laure

    Hello Roee, thank you very much for your response. What is the specific helpers’s configuration?  I have followed the installation steps in Cloudinary's documentation (Adding gem + Api key in yml). With these same steps only,  cl_image_tag was working fine in another app, a week ago, that's why I'm confused. Thank you again.

    0
    Comment actions Permalink
  • Avatar
    Roee Ben Ari

    Hi Laure. 

    If you're using our ruby GEM, then the initialization of CloudinaryHelper is done on this line:

    https://github.com/cloudinary/cloudinary_gem/blob/d36c508af2b1b3ecea8b4d08a9d1d1813a5c23fc/lib/cloudinary/railtie.rb#L6

    You can also add it separately to projects using:

    include CloudinaryHelper
    0
    Comment actions Permalink
  • Avatar
    Laure

    Hi,

    I did use your ruby Gem, but I'm still getting

    undefined method `cl_image_tag'

    Thanks again.

    Best

    0
    Comment actions Permalink
  • Avatar
    Roee Ben Ari

    Hi Laure, following our corresponding over the support ticket, thank you for letting us know that everything works fine now :)

    0
    Comment actions Permalink
  • Avatar
    Laure

    Hi Roee,

    Yes, after I started using Carrierwave, it all started working out.

    Thanks for the support.

    Best.

    0
    Comment actions Permalink
  • Avatar
    Gabriel

    Same problem :(
    Included CloudinaryHelper and it is still undefined inside the controller.

    0
    Comment actions Permalink
  • Avatar
    Roee Ben Ari

    Hi Gabriel,

    Would you mind sharing a minimal code snippet that demonstrates the issue?

    Thanks,

    Roee

    1
    Comment actions Permalink
  • Avatar
    Gabriel

    Hey Roee,

    Thanks for your answer. For sure, below is my controller code, where I try to access my img path through cl_image_path:

    class Api::V1::ShowsController < ApplicationController
    include CloudinaryHelper
    [...]
    def create
    @show = Show.new(show_params)
    authorize @show
    if @show.save && @show.persisted?
    @show.upload_img(params[:photo])
    path = CloudinaryHelper.cl_image_path(@show.photo.key)
    render json: {
    entity: @show.as_json(methods: :num_of_favorites),
    status: 201
    }, status: :created
    else
    render json: { status: 422, errors: @show.errors.full_messages },
    status: :unprocessable_entity
    end
    end
    [...]
    end

    My server logs:

    Cloudinary Storage (1648.7ms) Uploaded file to key: 373vw55ta1gynwjn1yl462rsiqkn (checksum: Byt0IPZjjNDxlUfAiBg+iQ==)
    [ActiveJob] Enqueued ActiveStorage::AnalyzeJob (Job ID: 47c4ba9c-1846-477a-9941-2b5f9c956bac) to Async(default) with arguments: #<GlobalID:0x00007f6978a8abe0 @uri=#<URI::GID gid://show-app-api/ActiveStorage::Blob/6>>

    Completed 500 Internal Server Error in 3909ms (ActiveRecord: 49.1ms | Allocations: 55046)
    NoMethodError (undefined method `cl_image_path' for CloudinaryHelper:Module):


    The image upload is successful, but I can't access the image path in my controller, in order that I can pass it to my React front-end :(

    Best regards,
    Gabriel

    0
    Comment actions Permalink
  • Avatar
    Daniel Mendoza

    @Gabriel

    Hmm that's odd, I was able to get it to work for me but maybe it can be the version of Ruby and Rails that is being used? What are your versions?
    Also, if you open the rails console, and try

    include CloudinaryHelper
    CloudinaryHelper.cl_image_path("image/upload/sample.jpg")

    Does it return you the same error?

    0
    Comment actions Permalink

Please sign in to leave a comment.