Rails 显示随机图片
- 作者: 颜良师太
- 来源: 51数据库
- 2022-08-12
class HelloController < ApplicationController
def show
@images = ["image1.jpg", "image2.jpg", "image3.jpg", "image4.jpg", "image5.jpg"]
@random_no = rand(5)
@random_image = @images[@random_no]
end
end
推荐阅读
