Module: ScaffoldHelper

Defined in:
app/helpers/scaffold_helper.rb

Instance Method Summary collapse

Instance Method Details

#app_nameObject



33
34
35
# File 'app/helpers/scaffold_helper.rb', line 33

def app_name
  Rails.application.class.to_s.split("::").first.underscore.humanize
end

#default_collection_actions_for(content, scope = :admin) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/helpers/scaffold_helper.rb', line 2

def default_collection_actions_for(content, scope = :admin)
  buttons = []

  if subject.can_show?(content) && lookup_context.exists?('show', lookup_context.prefixes, false)
    buttons << link_to(t('fullstack.admin.show', :default => "Show"), self.send(:"#{scope}_#{resource_name}_path", content), :class => "btn")
  end

  if subject.can_edit?(content)
    buttons << link_to(t('fullstack.admin.edit', :default => "Edit"), self.send(:"edit_#{scope}_#{resource_name}_path", content), :class => "btn")
  end

  if subject.can_destroy?(content)
    buttons << link_to(t('fullstack.admin.delete', :default => "Delete"),
            self.send(:"#{scope}_#{resource_name}_path", content),
            :confirm => t('fullstack.admin.are_you_sure', :default => "Are you sure?"), :method => "delete",
            :remote => true,  :class => "btn hide btn-danger"
            )
  end
  "#{buttons.join('&nbsp;')}".html_safe
end

#has_locale?(model) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
# File 'app/helpers/scaffold_helper.rb', line 41

def has_locale?(model)
  model.columns_hash["locale"]
end

#has_timestamps?(model) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
# File 'app/helpers/scaffold_helper.rb', line 37

def has_timestamps?(model)
  model.columns_hash["created_at"]
end

#labelize_attribute_name(method) ⇒ Object



23
24
25
26
# File 'app/helpers/scaffold_helper.rb', line 23

def labelize_attribute_name(method)
method ||= "id" 
     I18n.t("helpers.label.#{method}", :default => method.to_s.humanize)
end

#positionable?(object_or_class) ⇒ Boolean

Returns:

  • (Boolean)


45
46
47
48
# File 'app/helpers/scaffold_helper.rb', line 45

def positionable?(object_or_class)
  model = object_or_class.is_a?(Class) ? object_or_class : object_or_class.class
  model.ancestors.include?(Positionable)
end

#skip_filterObject



54
55
56
# File 'app/helpers/scaffold_helper.rb', line 54

def skip_filter
  @skip_filter
end

#skip_filter!Object



50
51
52
# File 'app/helpers/scaffold_helper.rb', line 50

def skip_filter!
  @skip_filter = true
end


28
29
30
31
# File 'app/helpers/scaffold_helper.rb', line 28

def sort_link(method)
  method = "#{method}"
  super(@search, method, labelize_attribute_name(method))
end