【发布时间】:2014-11-23 13:17:02
【问题描述】:
我正在使用 devise 和 rails 4。我有以下模型:
class Video
include Mongoid::Document
include Mongoid::Timestamps
field :url, type: String
field :video_id, type: String
field :title, type: String
field :description, type: String
field :suggested_by_name, type: String
field :suggested_by_email, type: String
field :active, type: Boolean, default: false
end
使用以下控制器:
class Frontend::VideosController < ApplicationController
before_action :authenticate_user!, only: [:index, :edit, :update, :destroy]
def index
end
def new
@videos = Video.new
end
def create
if @person = Video.create(params[:video])
flash.now[:success] = "Thanks for suggest this video"
redirect_to root_path
else
flash.now[:error] = "Impossible to add this suggestion"
redirect_to new_frontend_video_path
end
end
def edit
end
def update
end
def destroy
end
private
def video_params
params.require(:video).permit(:url, :title, :description, :suggested_by_name, :suggested_by_email)
end
end
我正在尝试在我的 mongodb 上保存记录,但我得到:
ActiveModel::ForbiddenAttributesError
所以我认为我在使用强参数时犯了一个错误,请帮忙。
【问题讨论】:
标签: ruby-on-rails mongodb devise