Having a problem with a Paperclip upload in Rails 4 - failing on ForbiddenAttributesError (strong parameters validation). Have the latest paperclip gem and latest rails 4 g
It looks like your first one should have worked. This is what I use for my projects.
class GalleriesController < ApplicationController
def new
@gallery = Gallery.new
end
def create
@user.galleries.new(gallery_params)
end
private
#note cover_image is the name of paperclips attachment filetype(s)
def gallery_params
params.require(:gallery).permit(:cover_image)
end
end
I understand what happened here now - and will leave this up in the hope it helps someone else. I was porting code from a rails 3 project and missed the line that created the image:
@image = current_user.images.new(params[:image])
In rails 4 this is incorrect (I beleive). I updated to
@image = current_user.images.new(image_params)
and that solved my problem.