Method: Post.post_types_for_select

Defined in:
app/models/post.rb

.post_types_for_selectObject



178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# File 'app/models/post.rb', line 178

def self.post_types_for_select
  results = []
  path_to_posttypes = File.join(::Rails.root, "app", "views", "posttypes")
  if Dir.exist?(path_to_posttypes)
    Dir.foreach(path_to_posttypes) do |name| #.map{|a| File.basename(a, ".html.erb")}.delete_if{|a| a =~ /^_edit/ }.delete_if{|a| a[0] == "_"}
      file_name_path = File.join(path_to_posttypes,name)
      if File.directory?(file_name_path)
        Dir.foreach(file_name_path) do |sub_name|
            file_name = "#{name}#{sub_name}" if File.exist?(File.join(file_name_path,sub_name)) && (sub_name =~ /^_(?!edit).*/) == 0
            results << file_name.split(".").first.to_s.titleize if file_name.present?
        end
      end
    end
  end
  return results
end