| Module | ResourceController::Helpers::CurrentObjects |
| In: |
../lib/resource_controller/helpers/current_objects.rb
|
Used to fetch the collection for the index method
In order to customize the way the collection is fetched, to add something like pagination, for example, override this method.
# File ../lib/resource_controller/helpers/current_objects.rb, line 16
16: def collection
17: end_of_association_chain.find(:all)
18: end
Used internally to load the collection in to an instance variable @#{model_name.pluralize} (i.e. @posts)
# File ../lib/resource_controller/helpers/current_objects.rb, line 55
55: def load_collection
56: instance_variable_set "@#{parent_type}", parent_object if parent?
57: instance_variable_set "@#{object_name.to_s.pluralize}", collection
58: end
Used internally to load the member object in to an instance variable @#{model_name} (i.e. @post)
# File ../lib/resource_controller/helpers/current_objects.rb, line 48
48: def load_object
49: instance_variable_set "@#{parent_type}", parent_object if parent?
50: instance_variable_set "@#{object_name}", object
51: end
Used to fetch the current member object in all of the singular methods that operate on an existing member.
Override this method if you‘d like to fetch your objects in some alternate way, like using a permalink.
class PostsController < ResourceController::Base
private
def object
@object ||= end_of_association_chain.find_by_permalink(param)
end
end
# File ../lib/resource_controller/helpers/current_objects.rb, line 41
41: def object
42: @object ||= end_of_association_chain.find(param) unless param.nil?
43: @object
44: end