Module ResourceController::Helpers::CurrentObjects
In: ../lib/resource_controller/helpers/current_objects.rb

Methods

Protected Instance methods

Builds the object, but doesn‘t save it, during the new, and create action.

[Source]

    # File ../lib/resource_controller/helpers/current_objects.rb, line 68
68:         def build_object
69:           @object ||= end_of_association_chain.send parent? ? :build : :new, object_params
70:         end

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.

[Source]

    # 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)

[Source]

    # 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)

[Source]

    # 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 internally to return the model for your resource.

[Source]

   # File ../lib/resource_controller/helpers/current_objects.rb, line 7
7:         def model
8:           model_name.to_s.camelize.constantize
9:         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

[Source]

    # 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

Returns the form params. Defaults to params[model_name] (i.e. params["post"])

[Source]

    # File ../lib/resource_controller/helpers/current_objects.rb, line 62
62:         def object_params
63:           params["#{object_name}"]
64:         end

Returns the current param.

Defaults to params[:id].

Override this method if you‘d like to use an alternate param name.

[Source]

    # File ../lib/resource_controller/helpers/current_objects.rb, line 26
26:         def param
27:           params[:id]
28:         end

[Validate]