Sha256: be04ba939adc7d568e75eca2f978e6762071ea1dd87164a64b5a9de2942a4c32

Contents?: true

Size: 646 Bytes

Versions: 22

Compression:

Stored size: 646 Bytes

Contents

module Jt
	class ToolboxGenerator < Rails::Generators::Base
		source_root File.expand_path("../templates", __FILE__)

		def create_initializer_file
			copy_file "jt-toolbox.yml", "config/jt-toolbox.yml"

			insert_into_file "config/routes.rb", "# https://github.com/mperham/sidekiq/wiki/Monitoring

require 'sidekiq/web'

class AdminConstraint
	def matches?(request)
		return false if !request.session['user_id']

		user = User.find_by_id(request.session['user_id'])
		user && user.is_admin?
	end
end

", before: "Rails.application.routes.draw do"

			route "mount Sidekiq::Web => '/sidekiq', :constraints => AdminConstraint.new"

		end
	end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
jt-rails-toolbox-2.8.1 lib/generators/jt/toolbox/toolbox_generator.rb
jt-rails-toolbox-2.8.0 lib/generators/jt/toolbox/toolbox_generator.rb
jt-rails-toolbox-2.7.0 lib/generators/jt/toolbox/toolbox_generator.rb
jt-rails-toolbox-2.6.0 lib/generators/jt/toolbox/toolbox_generator.rb
jt-rails-toolbox-2.5.0 lib/generators/jt/toolbox/toolbox_generator.rb
jt-rails-toolbox-2.4.3 lib/generators/jt/toolbox/toolbox_generator.rb
jt-rails-toolbox-2.4.2 lib/generators/jt/toolbox/toolbox_generator.rb
jt-rails-toolbox-2.4.1 lib/generators/jt/toolbox/toolbox_generator.rb
jt-rails-toolbox-2.4.0 lib/generators/jt/toolbox/toolbox_generator.rb
jt-rails-toolbox-2.3.1 lib/generators/jt/toolbox/toolbox_generator.rb
jt-rails-toolbox-1.3.1 lib/generators/jt/toolbox/toolbox_generator.rb
jt-rails-toolbox-1.3.0 lib/generators/jt/toolbox/toolbox_generator.rb
jt-rails-toolbox-2.3.0 lib/generators/jt/toolbox/toolbox_generator.rb
jt-rails-toolbox-2.2.2 lib/generators/jt/toolbox/toolbox_generator.rb
jt-rails-toolbox-2.2.1 lib/generators/jt/toolbox/toolbox_generator.rb
jt-rails-toolbox-2.2.0 lib/generators/jt/toolbox/toolbox_generator.rb
jt-rails-toolbox-2.1.0 lib/generators/jt/toolbox/toolbox_generator.rb
jt-rails-toolbox-2.0.0 lib/generators/jt/toolbox/toolbox_generator.rb
jt-rails-toolbox-1.2.4 lib/generators/jt/toolbox/toolbox_generator.rb
jt-rails-toolbox-1.2.3 lib/generators/jt/toolbox/toolbox_generator.rb