Skip to content
Open
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@
/test/dummy/tmp/development_secret.txt

.byebug_history

.DS_Store
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ RakeUi.configuration do |config|
config.allow_production = true
end
```
The `staging` environment will be available by default. If you determine this is a risk, you can disable that.
```rb
RakeUi.configuration do |config|
config.allow_staging = false
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
5 changes: 4 additions & 1 deletion app/controllers/rake_ui/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ module RakeUi
class ApplicationController < ActionController::Base
before_action :black_hole_production

STAGING_OK = (Rails.env.staging? && RakeUi.configuration.allow_staging)
PROD_OK = RakeUi.configuration.allow_production

private

def black_hole_production
return if Rails.env.test? || Rails.env.development? || RakeUi.configuration.allow_production
return if Rails.env.test? || Rails.env.development? || STAGING_OK || PROD_OK

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

module RakeUi
mattr_accessor :allow_production
mattr_accessor :allow_staging

self.allow_production = false
self.allow_staging = true

def self.configuration
yield(self) if block_given?
Expand Down