我正在尝试通过 Ajax 调用提交文档和嵌入文档,但一直收到“未经允许的参数”异常。这是我的模型:
class UserForecast
...
embeds_many :time_entries
accepts_nested_attributes_for :time_entries
...
end
我的强大参数:
def user_forecast_params
params.require(:user_forecast).permit(:published, :user_id, :forecast_id, :project_role_id, time_entries_attributes: [:entry_date, :hours])
end
ajax 调用:
$.ajax({
url : '/user_forecasts.json' ,
data : { user_forecast: { user_id: timeEntry.data('user_id'), forecast_id: timeEntry.data('forecast_id'), project_role_id: timeEntry.data('project_role_id'), time_entries: { entry_date: timeEntry.data('date'), hours: timeEntry.value } }},
type : 'post',
...
我看不到我遗漏的任何东西,但我在日志中收到了这个:
Unpermitted parameter: time_entries
我正在使用:Ruby 2.3.0 Rails:4.2.6 Mongoid:5.1.5
谢谢你们!