module Undercarriage::Controllers::Restful::Actions::IndexConcern
Index restful action
Usage
class ExamplesController < ApplicationController include Undercarriage::Controllers::RestfulConcern end
Public Instance Methods
index()
click to toggle source
Index action
Usage
class ExamplesController < ApplicationController include Undercarriage::Controllers::RestfulConcern ## # This method is only needed if you want to override the action entirely. Otherwise, it is not needed. # Database resources can be accessed as `@index_resources` or `@examples` # # def index # ... # end end
# File lib/undercarriage/controllers/restful/actions/index_concern.rb, line 41 def index; end
Protected Instance Methods
resources_content()
click to toggle source
Index restful action
Usage
class ExamplesController < ApplicationController include Undercarriage::Controllers::RestfulConcern ## # This method is only needed if you want to override the query entirely. Otherwise, it is not needed. # Database resources can be accessed as `@examples` # # def resources_content # ... # end ## # To add authorization through something like Pundit, the following could be used # # def resources_content # super # # authorize @examples # end end
# File lib/undercarriage/controllers/restful/actions/index_concern.rb, line 70 def resources_content resources_query = model_class.all instance_variable_set("@#{instances_name}", resources_query) end
Private Instance Methods
index_resources()
click to toggle source
# File lib/undercarriage/controllers/restful/actions/index_concern.rb, line 78 def index_resources @index_resources ||= resources_content end