I want to do a file upload feature with Rails4.
Now I don't use database so I can't use the rails' validation to check if user selected a file on the browser.
But I want to do as this, a self created model:
# app/models/my_feature.rb
class MyFeature
include ActiveModel::Model
attr_accessor :my_file
# How to do next?
end
I don't know how to write validation code in the model. I have tried:
validates :my_file, presence: true
But not worked. Is it also need to check validation in the controller?