解決したいこと
エラーの解決
###詳細
rubyでグループ作成機能があるwebアプリケーションを作っています。
グループ編集のところでどうしても表題のエラーが発生します。
何卒ご教授よろしくお願いします。
https://gyazo.com/605e6b8d4b3153ae35f36a4df3918d8c
routes
1Rails.application.routes.draw do 2 devise_for :users 3 root 'groups#index' 4 resources :users, only: [:index, :edit, :update] 5 resources :groups, only: [:new, :create, :edit, :update] do 6 resources :messages, only: [:index, :create] 7 namespace :api do 8 resources :messages, only: :index, defaults: { format: 'json' } 9 end 10 end 11end
edit
1.chat-group-form 2 %h1 チャットグループ編集 3 = render partial: 'form', locals: { group: @group }
controller
1class GroupsController < ApplicationController 2 before_action :set_group, only: [:edit, :update] 3 4 def index 5 end 6 7 def new 8 @group = Group.new 9 @group.users << current_user 10 end 11 12 def create 13 @group = Group.new(group_params) 14 if @group.save 15 redirect_to root_path, notice: 'グループを作成しました' 16 else 17 render :new 18 end 19 end 20 21 def edit 22 @group = Group.find(params[:id]) 23 end 24 25 def update 26 if @group.update(group_params) 27 redirect_to group_messages_path(@group), notice: 'グループを更新しました' 28 else 29 render :edit 30 end 31 end 32 33 private 34 def group_params 35 params.require(:group).permit(:name, user_ids: [] ) 36 end 37 38 def set_group 39 @group = Group.find(params[:id]) 40 end 41end
対応策
スペルミスは無いようです。
よろしくお願いします。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/01/24 12:24
2020/01/24 12:41
2020/01/24 12:55