Rails 3 - Understanding attr_accessible with paper_clip

Just started learning how to use paper_clip. I installed everything according to the instructions and tried to download the image (profile_pic) ...

I got an error that mass_pic cannot assign ...

so I added attr_accessible :: profile_pic

And that stopped this error. I am wondering, I do not have the "profile_pic" column in my user table. Instead, thanks to paper_clip, I have: t.string "profile_pic_file_name" t.string "profile_pic_content_type" t.integer "profile_pic_file_size" t.datetime "profile_pic_updated_at"

So, trying to figure out the rails, how can this fix the problem? Does the model set attr_accessible: profile_pic works as a wildcard for everything after pic, or is it some kind of paper_clip magic?

thank

+3
source share
1 answer

This is because the profile_pic attribute is set to access your column. Therefore, to define another column, mass_upload would have to be loaded.

+1
source

Source: https://habr.com/ru/post/1768771/


All Articles