added tags and statuses to faq

This commit is contained in:
Harry Bomrah 2014-06-18 14:32:57 +08:00
parent a456fe53da
commit c15ed696b8
1 changed files with 14 additions and 4 deletions

View File

@ -1,20 +1,28 @@
class FaqsController < ApplicationController
def index
faqs = Qa.filter_by_categories.collect do |qa|
faqs = Qa.can_display.order_by(:created_at=>'desc').filter_by_categories.collect do |qa|
statuses = qa.statuses.collect do |status|
{
"status" => status,
"status-class" => "status-#{status.downcase}"
}
end
{
"link_to_show" => OrbitHelper.url_to_show(qa.to_param),
"question" => qa.title
"question" => qa.title,
"statuses" => statuses
}
end
{
"data" => faqs,
"extras" => {"widget-title"=>"Faqs"}
"total_pages" => faqs.total_pages
}
end
def show
params = OrbitHelper.params
faq = Qa.find_by_param(params[:uid])
faq = Qa.can_display.find_by_param(params[:uid])
faqs_files = faq.qa_files.collect do |f|
{
"file_url" => f.file.url,
@ -27,10 +35,12 @@ class FaqsController < ApplicationController
"link_title" => f.title
}
end
tags = faq.tags.map{|tag| { "tag" => tag.name } } rescue []
{
"extras" => {"question" => faq.title,"answer" => faq.answer},
"faqs_links" => faqs_links,
"faqs_files" => faqs_files
"faqs_files" => faqs_files,
"tags" => tags
}
end