Class: Iord::GenericController

Inherits:
ApplicationController
  • Object
show all
Includes:
Controller
Defined in:
app/controllers/iord/generic_controller.rb

Instance Method Summary collapse

Methods included from Fields

#field_attribute, #field_form, #field_form_hash, #field_form_object, #field_label, #field_name, #field_value, #iordh

Methods included from Crud

#create, #create_collection, #create_resource, #destroy, #destroy_resource, #edit, #edit_resource, #index, #index_collection, #new, #new_resource, #show, #show_resource, #update, #update_resource

Methods included from Attriutes

#attrs, #edit_attrs, #form_attrs, #index_attrs, #new_attrs, #show_attrs

Methods included from ResourceUrl

#collection_url, #collection_url_defaults, #collection_url_method, #edit_resource_url, #edit_resource_url?, #edit_resource_url_method, #form_resource_url, #has_collection?, #new_resource_url, #new_resource_url?, #new_resource_url_method, #resource_url, #resource_url_method

Methods included from ResourceInfo

#action_path, #build_resource_attribute_names, #collection_name, #resource_attribute_names, #resource_class, #resource_name, #resource_name_u, #resource_path

Methods included from Defaults

#default

Instance Method Details

#build_resource_infoObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/iord/generic_controller.rb', line 7

def build_resource_info
  return original_build_resource_info if self.class.name != 'Iord::GenericController'
  path = request.path[1..-1].split('/')
  # if new or edit
  path.pop if path.last =~/^(new|edit)$/
  # if ID
  path.pop if path.last =~ /^[a-f0-9]+$/

  namespace = String.new
  if self.class.resource_namespace.is_a? Module
    namespace = self.class.resource_namespace.to_s + '::'
  elsif self.class.resource_namespace
    namespace = path[0..-2].join('/').camelize + '::'
  end

  class_name = path.last.camelize
  @collection_name = class_name.humanize
  resource_class = class_name.singularize
  @resource_name = resource_class.humanize
  @resource_name_u = resource_class.underscore
  @resource_class = (namespace + resource_class).constantize

  prepend_view_path Iord::GenericResolver.new(path[0..-2].join('/'), path.last)
  @action_path = path.join('_')

  @resource_path = path[0..-2].map { |i| i.to_sym }
end

#original_build_resource_infoObject



6
# File 'app/controllers/iord/generic_controller.rb', line 6

alias :original_build_resource_info :build_resource_info