Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ucb_site_announcements

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ucb_site_announcements

  • 0.3.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

UCB Site Announcements

The ucb_site_announcements Rails engine provides administrator management and site display for timed announcements.

Prerequisites

  • Ruby >= 3.0
  • Rails >= 7.0

Installation

To add the engine to a Rails application:

  1. Add the gem to your Gemfile:
gem "ucb_site_announcements"
  1. Run bundle install

  2. Install and run migrations

bin/rails ucb_site_announcements:install:migrations
bin/rails db:migrate
  1. Mount the engine in config/routes.rb:
mount UcbSiteAnnouncements::Engine => "/announcements" # set whatever URL you'd like to use here
  1. Set up a configuration block in config/initializers/ucb_site_announcements.rb - auth_callback is required.
# config/initializers/ucb_site_announcements.rb
UcbSiteAnnouncements.configure do |config|
  config.auth_callback = ->(controller) {
    # This will be called in the admin controller to determine if the current user can make changes
    # to the announcements
    #
    # "controller" is the current controller instance so it will have access to anything defined in your
    # ApplicationController
    #
    # Return true if the current user can view/edit announcements; false otherwise
    #
    # Example:
    # controller.current_user.admin?
  }
  config.time_zone = "Pacific Time (US & Canada)"
end

time_zone is optional, but will default to Pacific Time (US & Canada)

[!CAUTION] If you don't provide a setting for auth_callback all users will be able to access the admin section for announcements, which is probably not what you want.

  1. Migrate the database:
rake ucb_site_announcements:install:migrations
rake db:migrate

Creating and Managing Announcements

Access the admin inteface at, e.g. /announcements/admin (assuming you set the mount point at announcements in step 3)

Displaying Announcements

To display active announcements in application views:

<%= active_site_announcements %>

This will render Bootstrap alert components for each active announcement.

FAQs

Package last updated on 03 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc