title: Why it shows error after uploading photo in rails app after I changed the storage to cloudinary with carrierwave?
body: <p>I have recently changed the cloud storage of image to cloudinary integrated with carrierrwave in my Rails app. It perfectly works but the problem is that it shows error that the photo is blank after uploading image. Even though it is showing error, I have manually reloaded the root url, at that time photo was already uploaded... The problem is only in new post and editing post but updating profile picture and adding profile picture has no error. I have uploaded photo using <code>simple_form</code>. What am I missing, please help me to solve the problem. <a href="https://i.stack.imgur.com/btxrA.png" rel="nofollow noreferrer">This is the screenshot</a> of error page after uploading photo.</p>
  
  <p><br />
  While changing to cloudinary I have followed the following steps:</p>
  
  <ol>
  <li>I added <code>cloudinary.yml</code> in <code>config/</code> directory</li>
  <li>I included <code>cloudinary</code> in <code>photo_uploader.rb</code> and removed <code>storage :file</code>.</li>
  <li>Finally, I added <code>cl</code> tag in front of <code>image_tag</code> and made <code>cl_image_tag</code></li>
  </ol>
  
  <p>The <code>photo_uploader.rb</code> file is:</p>
  
  <pre><code>class PhotoUploader &lt; CarrierWave::Uploader::Base
    include Cloudinary::CarrierWave
    # storage :file
    def store_dir
      "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
    end
  end
  </code></pre>
  
  <p>My post controller file is:</p>
  
  <pre><code>class PostsController &lt; ApplicationController
      before_action :authenticate_user!, only: [:new, :create]
      before_action :is_owner?, only: [:edit, :update, :destroy]
  
      def index
        @posts = Post.all.order('created_at DESC').includes(:user, comments: :user).paginate(:page =&gt; params[:page], :per_page =&gt; 10)
      end
  
      def new
        @post = Post.new
      end
  
      def create
        @post = current_user.posts.create(post_params)
        if @post.valid?
          flash[:success] = "Your photo has been successfully posted!"
          redirect_to root_path
        else
          flash[:alert] = "Woops! Looks like there has been an error!"
          render :new, status: :unprocessable_entity
        end
      end
  
      def edit
        @post = Post.find(params[:id])
      end
  
      def update
        @post = Post.find(params[:id])
        @post.update(post_params)
        if @post.valid?
          flash[:success] = "Your post has been successfully updated!"
          redirect_to root_path
        else
          flash[:alert] = "Woops! Looks like there has been an error!"
          render :edit, status: :unprocessable_entity
        end
      end
  
      def show
        @post = Post.find(params[:id])
      end
  
      def destroy
        @post = Post.find(params[:id])
        @post.destroy
        flash[:success] = "The post was successfully deleted!"
        redirect_to root_path
      end
  
      private
  
      def is_owner?
        redirect_to root_path if Post.find(params[:id]).user != current_user
      end
  
      def post_params
        params.require(:post).permit(:user_id, :photo, :description)
      end
  end
  </code></pre>
  
  <p>The main problem is that <code>else</code> statement of <code>create model</code> is executed instead of <code>valid</code>.
  How can I solve this please help me...</p>