我来自JS背景,Rails让我感到困惑。我想要一个随机图像出现。如果图像的得分为1200,我希望第二个随机图像显示得分在800-1600之间。我通过carrierwave和Amazon S3连接上传的图片。这是我的图像模型:
create_table "photos", force: :cascade do |t|
t.integer "score"
t.integer "user_id"
t.integer "contest_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "image"
end
add_index "photos", ["contest_id"], name: "index_photos_on_contest_id", using: :btree
add_index "photos", ["user_id"], name: "index_photos_on_user_id", using: :btree
谢谢大家!