Class: Decidim::Feeds::Admin::FeedsController
- Inherits:
-
ApplicationController
- Object
- Admin::ApplicationController
- ApplicationController
- Decidim::Feeds::Admin::FeedsController
- Includes:
- Admin::ParticipatorySpaceAdminBreadcrumb
- Defined in:
- app/controllers/decidim/feeds/admin/feeds_controller.rb
Overview
Controller that allows managing feeds.
Instance Method Summary collapse
Instance Method Details
#copy ⇒ Object
68 69 70 |
# File 'app/controllers/decidim/feeds/admin/feeds_controller.rb', line 68 def copy :create, :feed end |
#create ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/controllers/decidim/feeds/admin/feeds_controller.rb', line 23 def create :create, :feed params[:created_by] = current_user @form = form(FeedForm).from_params(params) CreateFeed.call(@form) do on(:ok) do |feed| flash[:notice] = I18n.t("feeds.create.success", scope: "decidim.admin") redirect_to feeds_path end on(:invalid) do flash.now[:alert] = I18n.t("feeds.create.error", scope: "decidim.admin") render :new end end end |
#edit ⇒ Object
42 43 44 45 46 |
# File 'app/controllers/decidim/feeds/admin/feeds_controller.rb', line 42 def edit :update, :feed, feed: current_feed @form = form(FeedForm).from_model(current_feed) render layout: "decidim/admin/feed" end |
#index ⇒ Object
13 14 15 16 |
# File 'app/controllers/decidim/feeds/admin/feeds_controller.rb', line 13 def index :read, :feed_list @feeds = collection end |
#new ⇒ Object
18 19 20 21 |
# File 'app/controllers/decidim/feeds/admin/feeds_controller.rb', line 18 def new :create, :feed @form = form(FeedForm).instance end |
#update ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'app/controllers/decidim/feeds/admin/feeds_controller.rb', line 48 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.admin") redirect_to edit_feed_path(feed) end on(:invalid) do flash.now[:alert] = I18n.t("feeds.update.error", scope: "decidim.admin") render :edit, layout: "decidim/admin/feed" end end end |