(Rails 5) cl_image_tag error
Hello!
On my rails app/view, when I'm running :
<%= cl_image_tag("gmp3zbi3syluyslnobox.jpg") %>
it return:
undefined method `cl_image_tag' for #<#<Class:0x00007f8dc9a3a6c0>:0x00007f8dca1998d0>
I think the gem setup is ok, I can't find what's going wrong.
Thank you very much for your help.
-
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 -
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 -
Hi Laure.
If you're using our ruby GEM, then the initialization of CloudinaryHelper is done on this line:
You can also add it separately to projects using:
include CloudinaryHelper
0 -
Hi,
I did use your ruby Gem, but I'm still getting
undefined method `cl_image_tag'
Thanks again.
Best
0 -
Hi Laure, following our corresponding over the support ticket, thank you for letting us know that everything works fine now :)
0 -
Hi Roee,
Yes, after I started using Carrierwave, it all started working out.
Thanks for the support.
Best.
0 -
Same problem :(
Included CloudinaryHelper and it is still undefined inside the controller.0 -
Hi Gabriel,
Would you mind sharing a minimal code snippet that demonstrates the issue?Thanks,
Roee
1 -
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
[...]
endMy 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,
Gabriel0 -
@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
Post is closed for comments.
Comments
10 comments