I am porting an application that uses Carrierwave for Rails 4, but I have problems with strong parameters. I have a model with
accepts_nested_attributes_for :photos
Here's how the uploaded images are transferred:
{
"model"=>
{
"photos_attributes"=>
{
"1362752177921"=>
{
"image"=>"test.jpg",
}
}
}
}
However, I cannot figure out how to write the parameters that will take photos_attributes.
I tried .permit(photos_attributes: []), but it just skips them when I use permit!, uuidwhich is created before the save does not appear in SQL, and this is the second problem:
photos.uuid may not be NULL: INSERT INTO "photos" ("created_at", "model_id", "image", "title", "updated_at") VALUES (?, ?, ?, ?, ?)
There is no documentation on strong parameters here, and I don’t even know how to do it.
Update
This worked with nested attributes:
params.permit( ..., :photos_attributes => ['id', 'title', 'image', '_destroy'])
, Rails 4 Carrierwave Nested Form. . ( _) Rails 3.