test/dummy/app/controllers/images_controller.rb in attached-1.0.0 vs test/dummy/app/controllers/images_controller.rb in attached-1.0.1
- old
+ new
@@ -30,19 +30,21 @@
respond_with(@image)
end
# POST /images
def create
- @image = Image.create(params[:image])
+ @image = Image.create(attributes)
@image.save
respond_with(@image)
end
# PUT /images/1
def update
@image = Image.find(params[:id])
+ @image.attributes = attributes
+ @image.save
respond_with(@image)
end
# DELETE /images/1
@@ -50,7 +52,14 @@
@image = Image.find(params[:id])
@image.destroy
respond_with(@image)
end
+
+private
+
+ def attributes
+ params.require(:image).permit(:name, :file)
+ end
+
end