class Admin::FaqsController < OrbitAdminController before_filter :setup_vars def index @table_fields = [:status,:category,:title,:tags] @categories = @module_app.categories @tags = @module_app.tags @filter_fields = filter_fields(@categories, @tags) @qas = Qa.order_by(sort) .with_categories(filters("category")) .with_tags(filters("tag")) .with_status(filters("status")) @qas = search_data(@qas,[:title]).page(params[:page]).per(10) render :partial => "index" if request.xhr? end def new @qa = Qa.new @tags = @module_app.tags @categories = @module_app.categories respond_to do |format| format.html # new.html.erb format.xml { render :xml => @qa } end end def create @qa = Qa.new(create_params) @qa.create_user_id = current_user.id @qa.update_user_id = current_user.id @qa.save redirect_to params['referer_url'] end def edit @qa = Qa.find(params[:id]) if can_edit_or_delete?(@qa) @tags = @module_app.tags @categories = @module_app.categories else render_401 end end def update @qa = Qa.find(params[:id]) @qa.update_attributes(create_params) @qa.update_user_id = current_user.id @qa.save redirect_to params['referer_url'] end def destroy @qa = Qa.find(params[:id]) @qa.destroy redirect_to admin_faqs_path end private def setup_vars @module_app = ModuleApp.where(:key => "faq").first end def create_params params.require(:qa).permit! end end