added scope and few mods in controller
This commit is contained in:
parent
c15ed696b8
commit
96a612af50
|
@ -1,6 +1,7 @@
|
|||
class FaqsController < ApplicationController
|
||||
def index
|
||||
faqs = Qa.can_display.order_by(:created_at=>'desc').filter_by_categories.collect do |qa|
|
||||
faqs = Qa.can_display.order_by(:created_at=>'desc').filter_by_categories
|
||||
f = faqs.collect do |qa|
|
||||
statuses = qa.statuses.collect do |status|
|
||||
{
|
||||
"status" => status,
|
||||
|
@ -14,8 +15,8 @@ class FaqsController < ApplicationController
|
|||
}
|
||||
end
|
||||
{
|
||||
"data" => faqs,
|
||||
"extras" => {"widget-title"=>"Faqs"}
|
||||
"data" => f,
|
||||
"extras" => {"widget-title"=>"Faqs"},
|
||||
"total_pages" => faqs.total_pages
|
||||
}
|
||||
end
|
||||
|
|
|
@ -22,6 +22,9 @@ class Qa
|
|||
|
||||
accepts_nested_attributes_for :qa_files, :allow_destroy => true
|
||||
accepts_nested_attributes_for :qa_links, :allow_destroy => true
|
||||
|
||||
scope :can_display, ->{where(:is_hidden=>false).order_by([:is_top, :desc])}
|
||||
|
||||
|
||||
# belongs_to :qa_category
|
||||
|
||||
|
|
Loading…
Reference in New Issue