Module: ViewMapper::BelongsToView

Includes:
BelongsToParentModels
Defined in:
lib/view_mapper/views/belongs_to/belongs_to_view.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from BelongsToParentModels

#add_model_actions, #field_for, #find_parent_models, #is_model_dependency_action, #model_info_from_param, #parent_models, #validate_parent_model, #validate_parent_models, #virtual_attribute_for, #virtual_attribute_setter_for

Class Method Details

.source_rootObject



6
7
8
# File 'lib/view_mapper/views/belongs_to/belongs_to_view.rb', line 6

def self.source_root
  File.expand_path(File.dirname(__FILE__) + "/templates")
end

Instance Method Details

#manifestObject



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/view_mapper/views/belongs_to/belongs_to_view.rb', line 14

def manifest
  m = super.edit do |action|
    action unless is_model_dependency_action(action) || !valid
  end
  if valid
    m.template(
      "view_form.html.erb",
      File.join('app/views', controller_class_path, controller_file_name, "_form.html.erb")
    )
    add_model_actions(m) unless view_only?
  end
  m
end

#source_roots_for_viewObject



10
11
12
# File 'lib/view_mapper/views/belongs_to/belongs_to_view.rb', line 10

def source_roots_for_view
  [ BelongsToView.source_root, File.expand_path(source_root), File.join(self.class.lookup('model').path, 'templates') ]
end

#validateObject



28
29
30
31
# File 'lib/view_mapper/views/belongs_to/belongs_to_view.rb', line 28

def validate
  super
  @valid &&= validate_parent_models
end