Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow running the UI in production #20

Merged
merged 2 commits into from
Feb 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.

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).

## [0.1.0]

* Adds `allow_production` configuration option

## [0.0.1]
* Setup CI and Gem Publishing, add better form Validations
[#10](https://github.com/doximity/rake-ui/pull/10)
Expand All @@ -26,4 +30,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
* Add RakeTask Model
[#2](https://github.com/doximity/rake-ui/pull/2)
* Initialize Rake UI Engine
[#1](https://github.com/doximity/rake-ui/pull/1)
[#1](https://github.com/doximity/rake-ui/pull/1)
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
rake-ui (0.0.1)
rake-ui (0.1.0)
actionpack
activesupport
railties
Expand Down Expand Up @@ -183,4 +183,4 @@ DEPENDENCIES
standardrb

BUNDLED WITH
2.2.8
2.2.14
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ NOTE: Relative to mountpoint in application
Add this line to your application's Gemfile:

```ruby
group :development do
gem 'rake-ui'
end
gem 'rake-ui'
```

And then execute:
Expand All @@ -46,7 +44,13 @@ end

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

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.
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.

```rb
RakeUi.configuration do |config|
config.allow_production = true
end
```

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)

Expand Down
4 changes: 3 additions & 1 deletion app/controllers/rake_ui/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ class ApplicationController < ActionController::Base
private

def black_hole_production
raise ActionController::RoutingError, "Not Found" unless Rails.env.test? || Rails.env.development?
return if Rails.env.test? || Rails.env.development? || RakeUi.configuration.allow_production

raise ActionController::RoutingError, "Not Found"
end
end
end
7 changes: 7 additions & 0 deletions lib/rake-ui.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,11 @@
require "rake-ui/engine"

module RakeUi
mattr_accessor :allow_production
self.allow_production = false

def self.configuration
yield(self) if block_given?
self
end
end
2 changes: 1 addition & 1 deletion lib/rake-ui/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module RakeUi
VERSION = "0.0.1"
VERSION = "0.1.0"
end