Sha256: 4e4dcaab412e0079cbf6504a02a1812956e9b5983ec3d24f9d59052f1c82ad2c
Contents?: true
Size: 1.29 KB
Versions: 1
Compression:
Stored size: 1.29 KB
Contents
module Popolo class OrganizationsController < 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, :posts, :post] before_filter :validate_path, only: [:nested_index, :nested_show, :posts, :post] def index @organizations = Organization.roots index! end def nested_index @organizations = @organization.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 def posts @posts = @organization.posts end def post @post = Post.find_by(organization_id: @organization, slug: params[:id]) end protected # @raises [Mongoid::Errors::DocumentNotFound] if a resource is improperly nested def validate_path parts = params[:path].split '/' parts.each do |part| @organization = Organization.find_by(parent_id: @organization, 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/organizations_controller.rb |