Rails: render doesn't work, still get `Template is missing`

后端 未结 5 756
一个人的身影
一个人的身影 2021-02-02 08:59

I am currently learning Rails Guides. I went through the steps but still encountered a mistake.

My Ruby version is ruby 2.1.1p76 and the Rails version is

5条回答
  •  迷失自我
    2021-02-02 09:58

    If you want to see textual information of params[:article] on your page then you can use render text

    try this

    class ArticlesController < ApplicationController
      def new
      end
    
      def create
        render text: params[:article].inspect
      end    
    end
    

    You will get

    {"title"=>"First article!", "text"=>"This is my first article."}
    # i.e. your params(whatever params hash contains)
    

提交回复
热议问题