Add download for articles
This commit is contained in:
parent
b6f5295267
commit
5a9cc811c9
5 changed files with 52 additions and 0 deletions
|
|
@ -21,6 +21,12 @@ class ArticlesController < ApplicationController
|
|||
end
|
||||
|
||||
@articles = Article.undeleted.where(supplier_id: @supplier, :type => nil).includes(:article_category).order(sort)
|
||||
|
||||
if request.format.csv?
|
||||
send_data ArticlesCsv.new(@articles, encoding: 'utf-8').to_csv, filename: 'articles.csv', type: 'text/csv'
|
||||
return
|
||||
end
|
||||
|
||||
@articles = @articles.where('articles.name LIKE ?', "%#{params[:query]}%") unless params[:query].nil?
|
||||
|
||||
@articles = @articles.page(params[:page]).per(@per_page)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue