Class: Decidim::Solutions::SolutionsController
- Inherits:
-
ApplicationController
- Object
- Components::BaseController
- ApplicationController
- Decidim::Solutions::SolutionsController
- Includes:
- ApplicationHelper, OrderableSolutions, WithDefaultFilters, WithSdgs, FilterResource, FormFactory, Paginable
- Defined in:
- app/controllers/decidim/solutions/solutions_controller.rb
Overview
Controller that allows browsing solutions.
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/controllers/decidim/solutions/solutions_controller.rb', line 45 def create :create, :solution @form = form(Decidim::Solutions::SolutionsForm).from_params(params.merge({ author_id: current_user.id })) Decidim::Solutions::CreateSolution.call(@form) do on(:ok) do flash[:notice] = I18n.t("solutions.create.success", scope: "decidim.solutions") redirect_to solutions_path end on(:invalid) do flash.now[:alert] = I18n.t("solutions.create.error", scope: "decidim.solutions") render action: "new" end end end |
#index ⇒ Object
24 25 26 27 28 |
# File 'app/controllers/decidim/solutions/solutions_controller.rb', line 24 def index @solutions = search.result @solutions = reorder(@solutions) @solutions = paginate(@solutions) end |
#new ⇒ Object
40 41 42 43 |
# File 'app/controllers/decidim/solutions/solutions_controller.rb', line 40 def new :create, :solution @form = form(Decidim::Solutions::SolutionsForm).instance end |
#show ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'app/controllers/decidim/solutions/solutions_controller.rb', line 30 def show @solution = solution if @solution.problem.present? @sectorial_scope = sectorial_scope @technological_scope = technological_scope end @sdg_index = sdg_index if @solution.problem.present? || @solution.challenge.present? @challenge_scope = challenge_scope end |