Featured asciicasts
parent
305b948576
commit
b68e02212d
@ -1,6 +1,7 @@
|
|||||||
class HomeController < ApplicationController
|
class HomeController < ApplicationController
|
||||||
def show
|
def show
|
||||||
@asciicasts = Asciicast.order("created_at DESC").limit(10)
|
@asciicasts = Asciicast.order("created_at DESC").limit(10)
|
||||||
@asciicast = @asciicasts.first
|
offset = (Asciicast.featured.count * rand).to_i
|
||||||
|
@asciicast = Asciicast.featured.offset(offset).first || @asciicasts.first
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
class AddFeaturedToAsciicast < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :asciicasts, :featured, :boolean, :default => false
|
||||||
|
|
||||||
|
add_index :asciicasts, :featured
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue