Sha256: f729abeb30f99156d105ba6ec56d636dc1a8a9ac3665cb9398bd703d50be2a36

Contents?: true

Size: 704 Bytes

Versions: 1

Compression:

Stored size: 704 Bytes

Contents

# encoding: utf-8
module RademadeAdmin::FieldHelper

  def field_to_label(field)
    field.to_s.sub('_', ' ').capitalize
  end

  def pagination_option(number, name = 'paginate')
    hash_params = request.query_parameters.clone
    hash_params.delete(:page)
    hash_params[name.to_sym] = number

    options = '?' + hash_params.map do |k, v|
      "#{k.to_s}=#{v}"
    end.join('&')

    selected = number == request.query_parameters[name.to_sym].to_i

    content_tag(:option, number.to_s, selected: selected, value: request.path+options)
  end

  def input_attr(attrs = {})
    attrs.merge :wrapper_html => {:class => 'form-group'},
                :input_html => {:class => 'form-control'}
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rademade_admin-0.0.1 app/helpers/rademade_admin/field_helper.rb