LoginSignup
0
0

More than 3 years have passed since last update.

非同期通信の手順書②

Posted at

前提条件

以下のブログを読んでから本記事をお読みください。
非同期通信の手始めに

createアクションに何を記入するか

何をjsonで返して、何をHTMLで返すか…
それはrespond_toで決めるのでした。以下、コードです。

  def create
    @comment = Comment.create(comment_params)
    respond_to do |format|
      format.html { redirect_to tweet_path(params[:tweet_id])  }
      format.json
    end
  end

気付く人は気付きますがrender json 〇〇がありません。
これはこの後にjbuilderを用いるためです。
次はjbuilderについて記述します。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0