added scope and few mods in controller
This commit is contained in:
parent
c15ed696b8
commit
96a612af50
|
@ -1,6 +1,7 @@
|
||||||
class FaqsController < ApplicationController
|
class FaqsController < ApplicationController
|
||||||
def index
|
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|
|
statuses = qa.statuses.collect do |status|
|
||||||
{
|
{
|
||||||
"status" => status,
|
"status" => status,
|
||||||
|
@ -14,8 +15,8 @@ class FaqsController < ApplicationController
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
{
|
{
|
||||||
"data" => faqs,
|
"data" => f,
|
||||||
"extras" => {"widget-title"=>"Faqs"}
|
"extras" => {"widget-title"=>"Faqs"},
|
||||||
"total_pages" => faqs.total_pages
|
"total_pages" => faqs.total_pages
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,6 +23,9 @@ class Qa
|
||||||
accepts_nested_attributes_for :qa_files, :allow_destroy => true
|
accepts_nested_attributes_for :qa_files, :allow_destroy => true
|
||||||
accepts_nested_attributes_for :qa_links, :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
|
# belongs_to :qa_category
|
||||||
|
|
||||||
before_save :clean_values
|
before_save :clean_values
|
||||||
|
|
Loading…
Reference in New Issue