Class: Decidim::Plans::ApplicationController

Inherits:
Components::BaseController
  • Object
show all
Defined in:
app/controllers/decidim/plans/application_controller.rb

Overview

This controller is the abstract class from which all other controllers of this engine inherit.

Note that it inherits from ‘Decidim::Components::BaseController`, which override its layout and provide all kinds of useful methods.

Direct Known Subclasses

PlansController, VersionsController

Instance Method Summary collapse

Instance Method Details

#plan_limitObject



14
15
16
17
# File 'app/controllers/decidim/plans/application_controller.rb', line 14

def plan_limit
  return nil if component_settings.plan_limit.zero?
  component_settings.plan_limit
end

#plan_limit_reached?Boolean

Returns:

  • (Boolean)


19
20
21
22
23
# File 'app/controllers/decidim/plans/application_controller.rb', line 19

def plan_limit_reached?
  return false unless plan_limit

  plans.where(author: current_user).count >= plan_limit
end

#plansObject



25
26
27
# File 'app/controllers/decidim/plans/application_controller.rb', line 25

def plans
  Plan.where(component: current_component)
end