Module: AdminHelper

Defined in:
app/helpers/admin_helper.rb

Instance Method Summary collapse

Instance Method Details

#in_place(object, field, attributes = {}) ⇒ Object

define a bunch of defaults for the best_in_place call save and cancel buttons with internationlized texts bootstrap form class a default note same signature as best_in_place, ie object, field symbol , hash



14
15
16
17
18
19
20
# File 'app/helpers/admin_helper.rb', line 14

def in_place object , field , attributes ={}
  defaults = { :ok_button => I18n.t(:edit), :ok_button_class => "btn btn-success" ,
               :cancel_button => I18n.t(:cancel) , :cancel_button_class => "btn btn-warning",
               :place_holder => I18n.t(:edit)  , :inner_class => "form-control" }
  attributes.reverse_merge! defaults
  best_in_place(object , field , attributes)
end

#office_assetsObject



22
23
24
25
26
27
28
# File 'app/helpers/admin_helper.rb', line 22

def office_assets
  engines = Rails::Engine.subclasses.map(&:instance)
  engines << Rails.application
  engines.delete_if {|e| ! e.respond_to?(:office_assets) }
  assets = engines.collect{ |e| e.office_assets }
  assets.compact
end

#sort_date(key) ⇒ Object



4
5
6
7
# File 'app/helpers/admin_helper.rb', line 4

def sort_date key
  return "" unless params[:q]
  params[:q][key] || ""
end

#title(page_title) ⇒ Object

helper so one doesn’t hav to write the funny content_for in templates



31
32
33
# File 'app/helpers/admin_helper.rb', line 31

def title(page_title)
  content_for(:title) { page_title }
end