我只是想以随机顺序返回 DataMapper 记录。
这是我的模型(使用带有 sqlite3 数据库的 DataMapper):
class Movie
include DataMapper::Resource
DataMapper::Property::String.length(255)
property :id, Serial
property :title, String
property :img, String
property :description, String
property :year, String
property :created_at, DateTime
has n, :votes
belongs_to :user
end
这就是我返回记录的方式(Sinatra)
get '/' do
@movies = Movie.all # <-- What should this look like?
haml :home
end