Sha256: 9f9dbbf2cc1e15e59ab83edffc1e73671ebf89ec3ed3d000f81acaa58947984a
Contents?: true
Size: 1.05 KB
Versions: 1
Compression:
Stored size: 1.05 KB
Contents
module Popolo class AreasController < PopoloController inherit_resources # inherited_resources assumes the routes are namespaced. If an engine is # mounted at root, however, there will be no namespace. self.resources_configuration[:self][:route_prefix] = nil respond_to :html, :json actions :index, :show custom_actions collection: :nested_index, resource: :nested_show before_filter :validate_path, only: [:nested_index, :nested_show] def index @areas = Area.roots index! end def nested_index @areas = @area.children nested_index! do |format| format.html { render action: 'index'} end end def nested_show nested_show! do |format| format.html { render action: 'show'} end end protected # @raises [Mongoid::Errors::DocumentNotFound] if a resource is improperly nested def validate_path parts = params[:path].split '/' parts.each do |part| @area = Area.find_by(parent_id: @area, slug: part) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
popolo-0.0.2 | app/controllers/popolo/areas_controller.rb |