Sha256: 56795ea7158b85bdf855905fb35155e3de62d2c6b44812866511479fdd6cb8aa
Contents?: true
Size: 1.21 KB
Versions: 2
Compression:
Stored size: 1.21 KB
Contents
require 'digest' module Administrate module ApplicationHelper PLURAL_MANY_COUNT = 2.1 def gravatar_for_email(email, size = 120) hash = Digest::MD5.hexdigest(email) "//www.gravatar.com/avatar/#{hash}?s=#{size}" end def render_field(field, locals = {}) locals.merge!(field: field) render locals: locals, partial: field.to_partial_path end def class_from_resource(resource_name) resource_name.to_s.classify.constantize end def display_resource_name(resource_name) class_from_resource(resource_name). model_name. human( count: PLURAL_MANY_COUNT, default: resource_name.to_s.pluralize.titleize, ) end def sort_order(order) case order when "asc" then "ascending" when "desc" then "descending" else "none" end end def resource_index_route_key(resource_name) ActiveModel::Naming.route_key(class_from_resource(resource_name)) end def sanitized_order_params params.permit(:search, :id, :order, :page, :per_page, :direction, :orders) end def clear_search_params params.except(:search, :page).permit(:order, :direction, :per_page) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
semantic-administrate-0.1.1 | app/helpers/administrate/application_helper.rb |
semantic-administrate-0.1.0 | app/helpers/administrate/application_helper.rb |