title: How to keep the url saved after editing the post in forms
body: <p>I am working on a rails app. I have a form for new post that includes title, image, URL link, and a description. However, i faced an issue and that is whenever the user tries to update(edit) the post, the URL link disappears. The user has to rewrite the URL link everytime he has to update the post!</p>
  
  <p>Here's my edit.html.haml:</p>
  
  <pre><code>.col-md-6.col-md-offset-3
      .row
          .panel.panel-default
              .panel-heading
                  %h1 Edit Project
              .panel-body
                  = simple_form_for @post, html: { multipart: true } do |f|
                      - if @post.errors.any?
                          #errors
                              %h2
                                  = pluralize(@post.errors.count, "error")
                                  prevented this Post from saving
                              %ul
                                  - @post.errors.full_messages.each do |msg|
                                      %li= msg
  
                      .form-group
                          = f.input :title,:label =&gt; "Project Name", input_html: { class: 'form-control', :type =&gt; "text", :required =&gt; ""}
  
                      .form-group
                          = f.input :image,:label =&gt; "Image", input_html: { class: 'form-group',"aria-describedby" =&gt; "fileHelp", :required =&gt; "", :type =&gt; "file" }
  
                      .form-group
                          = f.input :link,:label =&gt; "Project Link", input_html: { class: 'form-control', :type =&gt; "url", :value =&gt; "https://", :required =&gt; "" }
  
  
                      .form-group
                          = f.input :description,:label =&gt; "Description", input_html: { class: 'form-control', :rows =&gt; "3", :required =&gt; "" }
  
  
                      %button.btn.btn-info{:type =&gt; "submit" } Update Project
  </code></pre>
  
  <p>Here my <code>posts_controller.rb</code>:</p>
  
  <pre><code>class PostsController &lt; ApplicationController
      before_action :find_post, only: [:show, :edit, :update, :destroy, :upvote]
      before_action :authenticate_user!, except: [:index, :show, :most_liked]
  
      def index
          @posts = Post.all.order("created_at DESC")
      end
  
      def most_liked
          @most_liked = Post.all.order(cached_votes_score: :DESC)
      end
  
      def show
          @comments = Comment.where(post_id: @post)
          @random_post = Post.where.not(id: @post).order("RANDOM()").first
      end
  
      def new
          @post = current_user.posts.build
      end
  
      def create
          @post = current_user.posts.build(post_params)
  
  
          respond_to do |format|
              if @post.save
                flash[:success] = 'YEs'
                format.html { redirect_to @post }
                format.json { render :show, status: :created, location: @post }
              else
                flash[:danger] = 'no'
                format.html { render :new }
                format.json { render json: @post.errors, status: :unprocessable_entity }
              end
          end
      end
  
      def edit
      end
  
      def update
          respond_to do |format|
              if @post.update(post_params)
                flash[:success] = 'Good'
                format.html { redirect_to @post }
                format.json { render :show, status: :ok, location: @post }
              else
                flash[:danger] = 'bad'
                format.html { render :edit }
                format.json { render json: @post.errors, status: :unprocessable_entity }
              end
          end
      end
  
      def destroy
          @post.destroy
          redirect_to root_path
      end
  
      def upvote
          @post.upvote_by current_user
          redirect_to :back
      end
  
      private
  
      def find_post
          @post = Post.find(params[:id])
      end
  
      def post_params
          params.require(:post).permit(:title, :link, :description, :image)
      end
  
  end
  </code></pre>
  
  <p>I could not find something similar to my question, please help! Thanks</p>