13 Jun 2013, 20:04
Generic-user-small

Mike Ruch (2 posts)

In section 21.4, Uploading Files to Rails Applications, the following line appears in the definition of the save action for the upload controller:

@picture = Picture.new(params[:picture])

Predictably, that threw an exception. I think it needs to be updated for strong parameters. I installed the protected attributes gem to get around it, but I’d be interested in seeing how you would set the strong parameters for a file upload.

thx

13 Jun 2013, 21:43
Generic-user-small

Mike Ruch (2 posts)

This actually wasn’t difficult. I changed the line to:

@picture = Picture.new(picture_params)

Then, I added the following to the controller:

private

def picture_params params.require(:picture).permit(:comment, :uploaded_picture) end

Everything worked fine after that.

14 Jun 2013, 00:01
Samr_small_pragsmall

Sam Ruby (584 posts)

Thanks! Will fix in next beta.

  You must be logged in to comment