From 1cc572e6311cbe5b14f21194162fefaaa21b74ac Mon Sep 17 00:00:00 2001 From: Saurabh Bhatia Date: Thu, 10 Apr 2014 11:52:59 +0800 Subject: [PATCH] added index page --- app/controllers/admin/announcements_controller.rb | 4 ++++ app/views/admin/announcements/index.html.erb | 3 +++ config/routes.rb | 5 +++-- lib/announcement/engine.rb | 1 + 4 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 app/views/admin/announcements/index.html.erb diff --git a/app/controllers/admin/announcements_controller.rb b/app/controllers/admin/announcements_controller.rb index 96606b6..433fdd0 100644 --- a/app/controllers/admin/announcements_controller.rb +++ b/app/controllers/admin/announcements_controller.rb @@ -8,6 +8,10 @@ class Admin::AnnouncementsController < ApplicationController @announcement.save end + def index + @announcements = Bulletin.all + end + private # Never trust parameters from the scary internet, only allow the white list through. diff --git a/app/views/admin/announcements/index.html.erb b/app/views/admin/announcements/index.html.erb new file mode 100644 index 0000000..0cb7a7f --- /dev/null +++ b/app/views/admin/announcements/index.html.erb @@ -0,0 +1,3 @@ +<% @announcements.each do |a|%> + <%= a.title %> +<% end %> \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 5fb352e..1699f8d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,7 +1,8 @@ Rails.application.routes.draw do - scope "(:locale)", locale: /en|zh_tw/ do - + locales = Site.find_by(site_active: true).in_use_locales + + scope "(:locale)", locale: Regexp.new(locales.join("|")) do namespace :admin do resources :announcements end diff --git a/lib/announcement/engine.rb b/lib/announcement/engine.rb index 0b66150..64252e8 100644 --- a/lib/announcement/engine.rb +++ b/lib/announcement/engine.rb @@ -8,6 +8,7 @@ module Announcement side_bar do head_label_i18n 'announcement.announcement', icon_class: "icons-megaphone" + active_for_controllers ({:private=>['announcements']}) head_link_path "admin_announcements_path" end end