2021-06-01から1ヶ月間の記事一覧

Herokuデプロイ時にハマったエラー

まずはHerokuのログを辿ってみる <ターミナル > heroku logs Failed to install gems via Bundler. zenn.dev qiita.com Precompiling assets failed. qiita.com

ルーティングをネストしている時のprefix

routes.rb #--- 略 --- resources :posts do resources :comments end rails routes prefix HTTPメソッド パス アクション post_comments GET /posts/:post_id/comments(.:format) comments#index POST /posts/:post_id/comments(.:format) comments#create …

ネストしているモデルに対するform_withの書き方

ユーザーが投稿した記事(post)に対してコメント(comment)する想定 comments_controller.rbの記述 def new @post = Post.find(params[:post_id]) ←現在の投稿のデータをインスタンスに入れておく @comment = Comment.new ←新規commentのインスタンス生成 …