diff --git a/app/controllers/statistics_controller.rb b/app/controllers/statistics_controller.rb index b7fd0b8c0..00cca9816 100644 --- a/app/controllers/statistics_controller.rb +++ b/app/controllers/statistics_controller.rb @@ -2,6 +2,7 @@ class StatisticsController < ApplicationController # GET /statistics # GET /statistics.json layout 'base_statistic' + before_filter :get_date, :only => [:index, :new, :edit] def index @statistics = Statistic.all @@ -82,4 +83,16 @@ class StatisticsController < ApplicationController format.json { head :no_content } end end + + def get_sub_category + respond_to do |format| + format.js + end + end + + private + def get_date + @main_categories = MainCategory.all + @sub_categories = params[:main_category_id].present? ? SubCategory.where(:main_category_id => params[:main_category_id]) : SubCategory.all + end end diff --git a/app/views/statistics/_form.html.erb b/app/views/statistics/_form.html.erb index 8b65ed2bc..4106aa5a2 100644 --- a/app/views/statistics/_form.html.erb +++ b/app/views/statistics/_form.html.erb @@ -18,25 +18,22 @@