Class: Decidim::Feeds::FeedsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Decidim::Feeds::FeedsController
- Includes:
- FilterResource, FormFactory, HasParticipatorySpaceContentBlocks, Paginable, ParticipatorySpaceContext
- Defined in:
- app/controllers/decidim/feeds/feeds_controller.rb
Overview
A controller that holds the logic to show Feeds in a public layout.
Instance Method Summary collapse
- #create ⇒ Object
- #edit ⇒ Object
-
#index ⇒ Object
helper_method :collection, :stats.
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/controllers/decidim/feeds/feeds_controller.rb', line 46 def create :create, :feed @form = form(FeedForm).from_params(params) CreateFeed.call(@form) do on(:ok) do |feed| flash[:notice] = I18n.t("feeds.create.success", scope: "decidim.feeds") redirect_to feeds_path end on(:invalid) do flash.now[:alert] = I18n.t("feeds.create.error", scope: "decidim.feeds") render :new end end end |
#edit ⇒ Object
64 65 66 67 68 |
# File 'app/controllers/decidim/feeds/feeds_controller.rb', line 64 def edit :update, :feed, feed: current_feed @form = form(FeedForm).from_model(current_feed) end |
#index ⇒ Object
helper_method :collection, :stats
19 20 21 22 23 |
# File 'app/controllers/decidim/feeds/feeds_controller.rb', line 19 def index :list, :feed @feeds = published_feeds.query end |
#new ⇒ Object
40 41 42 43 44 |
# File 'app/controllers/decidim/feeds/feeds_controller.rb', line 40 def new :create, :feed @form = form(FeedForm).instance end |
#show ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/controllers/decidim/feeds/feeds_controller.rb', line 25 def show :read, :feed, feed: current_participatory_space @feed = current_feed @posts_component = current_feed.components.find_by(manifest_name: "posts") if @posts_component.nil? flash[:alert] = I18n.t("feeds.show.posts_component_not_found", scope: "decidim.feeds") redirect_to feeds_path end # redirect_to decidim_feed_posts_path(current_participatory_space, posts_component) if posts_component end |
#update ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'app/controllers/decidim/feeds/feeds_controller.rb', line 70 def update :update, :feed, feed: current_feed @form = form(FeedForm).from_params( feed_params, feed_id: current_feed.id ) UpdateFeed.call(current_feed, @form) do on(:ok) do |feed| flash[:notice] = I18n.t("feeds.update.success", scope: "decidim.feeds") redirect_to feed end on(:invalid) do flash.now[:alert] = I18n.t("feeds.update.error", scope: "decidim.feeds") render :edit end end end |