Activeadminの管理者ユーザー画面から投稿しようとすると以下のエラーが発生します、、、
解決策を教えていただきたいです、、、
以下エラー画面
ActiveModel::ForbiddenAttributesError in Admin::ReviewsController#create ActiveModel::ForbiddenAttributesError Extracted source (around line #21): 19 20 21 22 23 24 def sanitize_for_mass_assignment(attributes) if attributes.respond_to?(:permitted?) raise ActiveModel::ForbiddenAttributesError if !attributes.permitted? attributes.to_h else attributes
以下コントローラー
class ReviewsController < ApplicationController before_action :move_to_index, except: :index def search @q = Review.ransack(params[:q]) @results = @q.result(distinct: true) end def index @review = Review.all.order(id: 'DESC').page(params[:page]).per(10) end def new @review = Review.new end def create @review = Review.new(review_params) @review.save redirect_to("/") end private def review_params params.permit(:bookname, :tag_list, :content, :level, :created_at, :updated_at).merge(user_id: current_user.id) end def move_to_index redirect_to action: :index unless user_signed_in? end end
あなたの回答
tips
プレビュー