Module: ScaffoldHelper
- Defined in:
- app/helpers/scaffold_helper.rb
Instance Method Summary collapse
- #app_name ⇒ Object
- #default_collection_actions_for(content, scope = :admin) ⇒ Object
- #has_locale?(model) ⇒ Boolean
- #has_timestamps?(model) ⇒ Boolean
- #labelize_attribute_name(method) ⇒ Object
- #positionable?(object_or_class) ⇒ Boolean
- #skip_filter ⇒ Object
- #skip_filter! ⇒ Object
- #sort_link(method) ⇒ Object
Instance Method Details
#app_name ⇒ Object
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) = [] if subject.can_show?(content) && lookup_context.exists?('show', lookup_context.prefixes, false) << link_to(t('fullstack.admin.show', :default => "Show"), self.send(:"#{scope}_#{resource_name}_path", content), :class => "btn") end if subject.can_edit?(content) << link_to(t('fullstack.admin.edit', :default => "Edit"), self.send(:"edit_#{scope}_#{resource_name}_path", content), :class => "btn") end if subject.can_destroy?(content) << 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 "#{.join(' ')}".html_safe end |
#has_locale?(model) ⇒ 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
37 38 39 |
# File 'app/helpers/scaffold_helper.rb', line 37 def (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
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_filter ⇒ Object
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 |
#sort_link(method) ⇒ Object
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 |