Module: ParamsParserHelper
- Included in:
- ApplicationController
- Defined in:
- lib/rails/generators/humdrum/layout/templates/helpers/params_parser_helper.rb
Instance Method Summary collapse
- #parse_filter_dates(instance_name, start_date_name = "start_date", end_date_name = "end_date") ⇒ Object
- #parse_pagination_params ⇒ Object
Instance Method Details
#parse_filter_dates(instance_name, start_date_name = "start_date", end_date_name = "end_date") ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rails/generators/humdrum/layout/templates/helpers/params_parser_helper.rb', line 15 def parse_filter_dates(instance_name, start_date_name="start_date", end_date_name="end_date") ## Parsing the date info if any unless params[instance_name][start_date_name].blank? d = params[instance_name][start_date_name] ? (Time.parse(params[instance_name][start_date_name])) : (Date.today - 1.day) @start_date = params[instance_name][:start_date] || (Date.today - 1.day) @start_time = Time.utc(d.year,d.month,d.day,00,00,00) end unless params[instance_name][end_date_name].blank? d = params[instance_name][end_date_name] ? Time.parse(params[instance_name][end_date_name]) : Date.today @end_date = params[instance_name][end_date_name] || Date.today @end_time = Time.utc(d.year,d.month,d.day,23,59,59) end end |
#parse_pagination_params ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/rails/generators/humdrum/layout/templates/helpers/params_parser_helper.rb', line 3 def parse_pagination_params @current_page = params[:page] || "1" @per_page = params[:per_page] || ConfigCenter::Defaults::ITEMS_PER_LIST.to_s if @per_page && @per_page.to_i > ConfigCenter::Defaults::MAX_ITEMS_PER_LIST @per_page = ConfigCenter::Defaults::ITEMS_PER_LIST.to_s end @offset = (@current_page.to_i - 1) * (@per_page.to_i) end |