Module: DmCore::ApplicationHelper
- Included in:
- DmCore::Admin::AdminController, UserDatatable
- Defined in:
- app/helpers/dm_core/application_helper.rb
Instance Method Summary collapse
-
#action?(*action) ⇒ Boolean
——————————————————————————.
-
#controller?(*controller) ⇒ Boolean
for determining if use is on a paritcular page, for active nav highlighting stackoverflow.com/questions/3705898/best-way-to-add-current-class-to-nav-in-rails-3 ——————————————————————————.
-
#flash_notices ⇒ Object
——————————————————————————.
-
#is_admin? ⇒ Boolean
——————————————————————————.
-
#is_sysadmin? ⇒ Boolean
——————————————————————————.
-
#link_to_add_custom_fields(name, f, association) ⇒ Object
——————————————————————————.
-
#present(object, klass = nil) {|presenter| ... } ⇒ Object
Used for accessing a models presenter object - can also accept a block ——————————————————————————.
-
#put_or_post? ⇒ Boolean
Usually don’t care if a form submits a PUT or POST.
Instance Method Details
#action?(*action) ⇒ Boolean
38 39 40 |
# File 'app/helpers/dm_core/application_helper.rb', line 38 def action?(*action) action.include?(params[:action]) end |
#controller?(*controller) ⇒ Boolean
for determining if use is on a paritcular page, for active nav highlighting stackoverflow.com/questions/3705898/best-way-to-add-current-class-to-nav-in-rails-3
33 34 35 |
# File 'app/helpers/dm_core/application_helper.rb', line 33 def controller?(*controller) controller.include?(params[:controller]) end |
#flash_notices ⇒ Object
14 15 16 17 18 |
# File 'app/helpers/dm_core/application_helper.rb', line 14 def flash_notices #--- use Bootstrap class values flash_class = {:notice => 'alert-success', :error => 'alert-error', :alert => 'alert-info'} raw([:notice, :error, :alert].collect {|type| content_tag('div', flash[type], :id => type, :class => "alert #{flash_class[type]}") if flash[type] }.join) end |
#is_admin? ⇒ Boolean
21 22 23 |
# File 'app/helpers/dm_core/application_helper.rb', line 21 def is_admin? user_signed_in? && current_user.is_admin? end |
#is_sysadmin? ⇒ Boolean
26 27 28 |
# File 'app/helpers/dm_core/application_helper.rb', line 26 def is_sysadmin? user_signed_in? && current_user.is_sysadmin? end |
#link_to_add_custom_fields(name, f, association) ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'app/helpers/dm_core/application_helper.rb', line 49 def link_to_add_custom_fields(name, f, association) new_object = f.object.send(association).klass.new id = new_object.object_id fields = f.simple_fields_for(association, new_object, child_index: id) do |builder| render('dm_core/admin/custom_fields/' + association.to_s.singularize + "_fields", f: builder) end link_to(name, '#', class: 'add_custom_fields btn btn-xs btn-default', data: {id: id, fields: fields.gsub("\n", "")}) end |
#present(object, klass = nil) {|presenter| ... } ⇒ Object
Used for accessing a models presenter object - can also accept a block
6 7 8 9 10 11 |
# File 'app/helpers/dm_core/application_helper.rb', line 6 def present(object, klass = nil) klass ||= "#{object.class}Presenter".constantize presenter = klass.new(object, self) yield presenter if block_given? presenter end |
#put_or_post? ⇒ Boolean
Usually don’t care if a form submits a PUT or POST. Was something submitted?
44 45 46 |
# File 'app/helpers/dm_core/application_helper.rb', line 44 def put_or_post? request.put? || request.post? || request.patch? end |