ユーザーが画像をアップロードする場合、セッション変数をtrueに設定し、セッション変数が設定されているかどうかをアップロードコントローラーで確認できます。ユーザーが画像をアップロードできるかどうかに依存します。セッション ストアを db に設定できます。さらに、セッションが保存される期間の範囲を定義できます。
コントローラ:
def new
@upload = YourUploadModel.new
session[:image_uploaded] ||= true
end
def create
if session[:image_uploaded] && session[:image_uploaded] == true
redirect_to root_path, :notice => "Already uploaded an image today!"
else
# create your upload..
end
end
app/config/initializers/session_store.rb:
# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
# (create the session table with "rails generate session_migration")
YourAppname::Application.config.session_store :active_record_store, {
expire_after: 1.days
}