I'm trying to build a Rails-based API to be consumed by an ember app. I'm working on project creation, and I'm running into some problems with strong parameters:
class ProjectsController < ApplicationController
def create
respond_with current_user.projects.create project_params
end
private
def project_params
params.require(:project).permit(:name)
end
end
So here I've got a controller that should accept a parameter has with a project object and the other details embedded in the project object.
This falls apart when I submit an empty form, which submits as {"project" => {}}.
, which throws
ActionController::ParameterMissing Exception: param is missing or the value is empty
I believe requiring the top level parameter is considered idiomatic, but it seems that the way ember removed empty parameter from the payload will cause problems in this case. How should this be handled?