【发布时间】:2013-07-11 09:22:43
【问题描述】:
我只是想用 Rails 建立一个博客,使用 MongoDB 作为我的持久层。作为其中的一部分,我想在我的帖子中嵌入 cmets,但每次我这样做时,它都会调用 ActiveModel::ForbiddenAttributesError 失败,我知道这与 Rails 中的 strong_parameters gem 有关。这就是我的控制器的样子
class CommentsController < ApplicationController
def create
@post = Post.find(params[:post_id])
@comment = @post.comments.create!(params[:comment])
redirect_to @post
end
private
def comment_params
params.require(:comment).permit(:by, :published_on, :body)
end
end
谁能看出我哪里出错了?
【问题讨论】:
标签: mongoid ruby-on-rails-4 strong-parameters