Class: Admin::AnnouncementsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Admin::AnnouncementsController
- Defined in:
- app/controllers/admin/announcements_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'app/controllers/admin/announcements_controller.rb', line 17 def create @announcement = Announcement.new(announcement_params) if @announcement.save redirect_to admin_announcements_path, :flash => { notice: 'Announcement created'} else render "new" end end |
#destroy ⇒ Object
36 37 38 39 |
# File 'app/controllers/admin/announcements_controller.rb', line 36 def destroy @announcement.destroy redirect_to admin_announcements_path, :flash => { notice: 'Announcement deleted' } end |
#edit ⇒ Object
14 15 |
# File 'app/controllers/admin/announcements_controller.rb', line 14 def edit end |
#index ⇒ Object
6 7 8 |
# File 'app/controllers/admin/announcements_controller.rb', line 6 def index @announcements = AnnouncementFinder.for_admin end |
#new ⇒ Object
10 11 12 |
# File 'app/controllers/admin/announcements_controller.rb', line 10 def new @announcement = Announcement.new_with_defaults end |
#update ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'app/controllers/admin/announcements_controller.rb', line 26 def update @announcement.attributes = announcement_params @announcement.roles = [] unless announcement_params.has_key?(:roles) if @announcement.save redirect_to admin_announcements_path, :flash => { notice: 'Announcement updated' } else render "edit" end end |