Files
componentowl-rails-archive/app/controllers/faqs_controller.rb

54 lines
1.1 KiB
Ruby

class FaqsController < ApplicationController
before_filter :init_objects, :except => [:search]
before_filter :init_params, :only => [:search]
caches_page :index, :show
def index
render :action => "show"
end
def show
end
def search
#buga> uz budou mit dalsi produkty faqs, tohle se musi predelat
@product = featured_product
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @faqs }
end
end
private
def init_params
params[:search] ||= {}
params[:search] ||= {}
params[:search][:order] ||= "ascend_by_position"
@search = Faq.search(params[:search])
@faqs = @search.all
end
def init_objects
if params[:product]
@product = Product[params[:product]]
@categories = @product.faq_categories.all_ordered
else
@categories = FaqCategory.common
end
if params[:id]
@categories.each {|category| @category = category if category.url_param == params[:id] }
else
@category = @categories.first
end
@faqs = @category.faqs
@products = Product.all_ordered
end
end