Rails 显示随机图片

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

编程技巧