サーバーを立てて、JSON形式で結果を出力したいです。
routes.rbに
Rails.application.routes.draw do namespace :connection do get '/',action:'index' end end
connection_controller.rbに
class ConnectionController < ApplicationController def index personal = {'name'=>'Yamada','old'=>28} render 'index',formats:'json',handlers:'jbuilder' end end
index.json.jbuilder(viewsのlayoutの下に置いた)に
json.post do |json| json.title @personal.name json.body @spersonal.old end
と書きました。
rails sでターミナルを立ち上げると
Template is missing
Missing template connection/index, application/index with {:locale=>[:en], :formats=>["json"], :variants=>[], :handlers=>["jbuilder"]}. Searched in: * "/Users/XXXX/Desktop/XXXXX/app/views"
とエラーが出ました。
viewとして置いたindex.json.jbuildeがおかしいとは思ったのですが、
http://t4traw.github.io/rails/2016061521-02.html
を参考にして作ったので、
どこを直せばいいのかわかりません。
どこを直せば良いのでしょうか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。