Search code examples
ruby-on-railsuploadstoragecloudinary

Cloudinary is working just fine from the rails console, but not from the form


I'm building a blog using ruby on rails.

Now I want to implement Cloudinary to handle de images from my development environment.

**I had checked on the Active Storage configuration and also cloudinary, but I'm not able to find the error. ** I can successfully upload pictures from rails console (rails c), but when I attempt to upload it from the form and click on create article, it displays the following error message:

Error image

Missing configuration for the cloudinary Active Storage service. Configurations available for the test and local services.

#line 15

14  def create
15    @article = Article.new(article_params)
16    if @article.save
17      redirect_to @article
18    else

Can someone give me a hand to find out where is the error and how to fix it? The project code is available here: https://github.com/ThePalmeraTech/la-central

Thank you!


Solution

  • I was able to upload the picture to Cloudinary now

    controller code:

     def create
        @article = Article.new(article_params)
        if params[:article][:photo].present?
          uploaded_image = Cloudinary::Uploader.upload(params[:article][:photo])
        end
    
        if @article.save
          redirect_to @article
        else
          render :new, status: :unprocessable_entity
        end
      end