Skip to content

Commit f27d4e5

Browse files
committed
allow running in production
1 parent 653e5ee commit f27d4e5

File tree

5 files changed

+24
-7
lines changed

5 files changed

+24
-7
lines changed

CHANGELOG.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [0.1.0]
8+
9+
* Adds `allow_production` configuration option
10+
711
## [0.0.1]
812
* Setup CI and Gem Publishing, add better form Validations
913
[#10](https://github.com/doximity/rake-ui/pull/10)
@@ -26,4 +30,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
2630
* Add RakeTask Model
2731
[#2](https://github.com/doximity/rake-ui/pull/2)
2832
* Initialize Rake UI Engine
29-
[#1](https://github.com/doximity/rake-ui/pull/1)
33+
[#1](https://github.com/doximity/rake-ui/pull/1)

README.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ NOTE: Relative to mountpoint in application
1717
Add this line to your application's Gemfile:
1818

1919
```ruby
20-
group :development do
21-
gem 'rake-ui'
22-
end
20+
gem 'rake-ui'
2321
```
2422

2523
And then execute:
@@ -46,7 +44,13 @@ end
4644

4745
This tool is built to enable developer productivity in development. It exposes rake tasks through a UI.
4846

49-
This tool will currently not work in production because we add a guard in the root controller to respond not found if the environment is development or test.
47+
This tool will currently not work in production because we add a guard in the root controller to respond not found if the environment is development or test. You may override this guard clause with the following configuration.
48+
49+
```rb
50+
RakeUi.configuration do |config|
51+
config.allow_production = true
52+
end
53+
```
5054

5155
We recommend adding guards in your route to ensure that the proper authentication is in place to ensure that users are authenticated so that if this were ever to be rendered in production, you would be covered. The best way for that is [router constraints](https://guides.rubyonrails.org/routing.html#specifying-constraints)
5256

app/controllers/rake_ui/application_controller.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ class ApplicationController < ActionController::Base
77
private
88

99
def black_hole_production
10-
raise ActionController::RoutingError, "Not Found" unless Rails.env.test? || Rails.env.development?
10+
return if Rails.env.test? || Rails.env.development? || RakeUi.configuration.allow_production
11+
12+
raise ActionController::RoutingError, "Not Found"
1113
end
1214
end
1315
end

lib/rake-ui.rb

+7
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,11 @@
33
require "rake-ui/engine"
44

55
module RakeUi
6+
mattr_accessor :allow_production
7+
self.allow_production = false
8+
9+
def self.configuration
10+
yield(self) if block_given?
11+
self
12+
end
613
end

lib/rake-ui/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module RakeUi
4-
VERSION = "0.0.1"
4+
VERSION = "0.1.0"
55
end

0 commit comments

Comments
 (0)