Sha256: 8f3dccaad10f31cdfbb613dad680acdc4492adf2caf4206106f41ff00030eb97

Contents?: true

Size: 879 Bytes

Versions: 3

Compression:

Stored size: 879 Bytes

Contents

module Adminpanel
	module SharedPagesHelper
		def parent_object_name(resource, parent_model)
			@model.reflect_on_all_associations.each do |association|
                if association.klass.to_s == parent_model
                	if !resource.send(association.name).nil?
                		return resource.send(association.name).name
                	else
                		return "N/A"
                	end
	            end
	        end
		end

		def pluralize_model(class_name)
			"#{demodulize_class(class_name).pluralize}"
		end

		def relationship_ids(class_string)
			"#{demodulize_class(class_string)}_ids"
		end

		def class_name_downcase(object)
			demodulize_class(object.class)
		end

		def demodulize_class(class_name)
			class_name.to_s.demodulize.downcase
		end

		def active_tab(index)
			if index == 0
				return "active"
			else
				return ""
			end
		end

	end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
adminpanel-1.2.8 app/helpers/adminpanel/shared_pages_helper.rb
adminpanel-1.2.7 app/helpers/adminpanel/shared_pages_helper.rb
adminpanel-1.2.6 app/helpers/adminpanel/shared_pages_helper.rb