title: Get json response from "create" function in rails 5
body: <pre><code>  # GET /posts/new
    def new
      @post = Post.new
    end
  
    # POST /posts
    # POST /posts.json
    def create
      @post = Post.new(post_params)
  
      respond_to do |format|
        if @post.save
          format.html { redirect_to @post, notice: 'Post was successfully created.' }
          format.json { render :show, status: :created, location: @post }
        else
          format.html { render :new }
          format.json { render json: @post.errors, status: :unprocessable_entity }
        end
      end
    end
  </code></pre>
  
  <p>i just want to know how to make "def create" return me the show.json.builder after save the post</p>
  
  <p>This is my form where i send the info to "def create", i already try to add the attribute :"data-type" => "json", but it doesn't work, and call by the method POST with the action "/posts.json" it doesn't call the function "create" just show all the information that contain the object post when i send it</p>
  
  <pre><code> &lt;%= form_for post do |f| %&gt;
  
  
       &lt;div class="field"&gt;
          &lt;%= f.label :title %&gt;
          &lt;%= f.text_field :title %&gt;
        &lt;/div&gt;
  
        &lt;div class="field"&gt;
          &lt;%= f.label :body %&gt;
          &lt;%= f.text_area :body %&gt;
        &lt;/div&gt;
  
        &lt;div class="actions"&gt;
          &lt;%= f.submit %&gt;
        &lt;/div&gt;
  
  
   &lt;% end %&gt;
  </code></pre>