3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/resource_controller/controller.rb', line 3
def self.included(subclass)
subclass.class_eval do
include ResourceController::Helpers
extend ResourceController::Accessors
before_filter :load_collection, :only => [:index]
before_filter :build_object, :only => [:new, :create]
before_filter :load_object, :only => [:show, :create, :update, :new, :edit, :destroy]
class_reader_writer :belongs_to, *NAME_ACCESSORS
NAME_ACCESSORS.each { |accessor| send(accessor, controller_name.singularize.underscore) }
self.helper_method :object_url, :edit_object_url, :new_object_url, :collection_url, :object, :collection,
:parent, :parent_type, :parent_object, :parent_model, :model_name, :model, :object_path,
:edit_object_path, :new_object_path, :collection_path, :hash_for_collection_path, :hash_for_object_path,
:hash_for_edit_object_path, :hash_for_new_object_path, :hash_for_collection_url,
:hash_for_object_url, :hash_for_edit_object_url, :hash_for_new_object_url, :parent?,
:collection_url_options, :object_url_options, :new_object_url_options
end
init_default_actions(subclass)
end
|