0
我想通過Ajax調用提交文檔和嵌入式文檔,但不斷收到「未經許可的參數」異常。 這是我的模型:嵌套的屬性不允許通過AJAX嵌入Mongoid文檔
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
謝謝大家!