ruby on rails - Strong params require works, but permit doesn't -


here's relevant rails code:

def update   project_id = update_params[:project] end  def update_params   params.require(:project).permit(:technology, :team_member) end 

and here's patch request (angular + coffeescript):

restangular.all("projects/#{$scope.projectid}")   .patch(team_member_delete: team_member.id, project: $scope.projectid) 

here's server sees:

parameters: {"technology_delete"=>7, "project"=>"64", "id"=>"64"} 

and here's full error server log:

started patch "/projects/64" ::1 @ 2015-06-12 17:23:40 -0400 processing projectscontroller#update html parameters: {"technology_delete"=>7, "project"=>"64", "id"=>"64"} completed 500 internal server error in 1ms (activerecord: 0.0ms)  nomethoderror (undefined method `permit' "64":string):   app/controllers/projects_controller.rb:73:in `update_params'   app/controllers/projects_controller.rb:29:in `update' 

the part says, "undefined method `permit' "64":string" makes me think it's interpreting 64 key, rather value.

here things i've tried:

  • formatting patch request parameters json (no change)
  • accessing params["project"] instead of params[:project] (no change)
  • sending 64 (an int) rather "64" (a string) (undefined method `permit' 64:fixnum)

i'm in rails 4.2.1, strong_params should pre-installed without gem. question looked promising, @ first, server log shows params hash, not string. rails 4 controller test "undefined method permit"

looks have 2 problems

first - odd

def update   project_id = update_params[:project] end 

usually, looks like

def update   project = project.find(id)   project.update_attributes(project_params)   ... end  private  def project_params   params.require(:project).permit(:technology, :team_member) end 

and second - form isn't submitting project params in right format - looks entire project missing. @joseph said, should in hash. add form view code if need help.


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -