Class: ArticlesController

Inherits:
Spree::BaseController
  • Object
show all
Defined in:
app/controllers/articles_controller.rb

Instance Method Summary collapse

Instance Method Details

#archiveObject



15
16
17
18
# File 'app/controllers/articles_controller.rb', line 15

def archive
  @articles = Article.find_articles(:year => params[:year], :month => params[:month])
  render :action => 'index'
end

#indexObject



4
5
6
7
8
9
10
11
12
13
# File 'app/controllers/articles_controller.rb', line 4

def index
  @per_page = 10
  @current_page = (params[:page] || 1).to_i
  @total_pages = (Article.count / @per_page.to_f).ceil
  @articles = Article.find_articles(:page => @current_page)
  respond_to do |wants|
    wants.html {}
    wants.xml {}
  end
end

#showObject



25
26
27
28
# File 'app/controllers/articles_controller.rb', line 25

def show
  key = "#{params[:year]}-#{params[:month].rjust(2,'0')}-#{params[:day].rjust(2,'0')}-#{params[:permalink]}"
  @article = Article.find(key)
end

#tagObject



20
21
22
23
# File 'app/controllers/articles_controller.rb', line 20

def tag
  @articles = Article.tagged(params[:tag])
  render :action => 'index'
end