ruby - Randomize order for DataMapper records -


I'm just returning the Datamaprint records in a random order .

Here is my model (sqlite3 database using datamapar):

  Datamapper in class movie :: resource datamapare :: property :: string.lombie (255) property : ID, serial property: title, string property: img, string property: description, string property: year, string property: made_at, datetime, en: voting related_to: user end   

and Here's how I am recording ( Inatra) Returning

  get '/' do @movies = movie. All # & lt; - What should it look like? Haml: home end    

I believe you can do it (based) Are:

  @movies = Movie.all.sort_by {rand}   

In addition, the same post Array # shuffle! and possibly drag something like this:

  @movies = Movie.all.shuffle #no! Since you are not changing the position; Not sure that DM supports it   

- or -

  @movies = movie.Sure @ movies.Space!    

Comments