How to Connect a File Uploader to a Rails Model
In this lesson, we are going to integrate the uploader into our Rails model because even though we already created an uploader for the application, the model file does not know that it exists.
Guide Tasks
  • Read Tutorial
  • Watch Guide Video
Video locked
This video is viewable to users with a Bottega Bootcamp license

In this lesson, we are going to integrate the uploader into our ActiveRecord model because even though we already created an uploader for the application, the model file does not know that it exists.

To do that, go to the model file post.rb and put this code in:

mount_uploader :image, PhotoUploader

medium

In this code, we are asking the application to mount the uploader and the database attribute that we want to upload is image. We are also calling the PhotoUploader because that's the class related to the uploading process.

So, that's how you integrate the uploader.