You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi there, in my Rails 5 app, I've managed to get attachinary working well with the singular (has_attachment), however, the plural/multiple files doesn't seem to be saving to my database / working in with ActiveRecord. They ARE being uploaded to my Cloudinary account but my database has no record of them. I'm applying this to a Campaign model. Any @campaign instance I create happily returns @campaign.image, @campaign.avatar. However, @campaign.photos, returns:
pry(#<CampaignsController>)> campaign.photos**
Attachinary::File Load (0.4ms) SELECT "attachinary_files".* FROM "attachinary_files" WHERE "attachinary_files"."attachinariable_id" = $1 AND "attachinary_files"."attachinariable_type" = $2 AND "attachinary_files"."scope" = $3 [["attachinariable_id", 50], ["attachinariable_type", "Campaign"], ["scope", "photos"]]
=> []
despite the fact that they ARE in my params (and uploaded to Cloudinary).
Hello,
The problem lies in the controller, the photos parameter is not properly referenced as the array it is.
You have params.require(:campaign).permit(:question, :option_1, :option_2, :user_id, :image, :photos, :avatar).merge(user)
Whereas you should have params.require(:campaign).permit(:question, :option_1, :option_2, :user_id, :image, photos: [], :avatar).merge(user)
Hi there, in my Rails 5 app, I've managed to get attachinary working well with the singular (has_attachment), however, the plural/multiple files doesn't seem to be saving to my database / working in with ActiveRecord. They ARE being uploaded to my Cloudinary account but my database has no record of them. I'm applying this to a Campaign model. Any @campaign instance I create happily returns @campaign.image, @campaign.avatar. However, @campaign.photos, returns:
despite the fact that they ARE in my params (and uploaded to Cloudinary).
Archive.zip
The text was updated successfully, but these errors were encountered: