Search code examples
ruby-on-railsrubyrubygemsruby-on-rails-5blocking

Blocking public access to my website with Coming-Soon page


I have a Rails website and it is live under root url. I want to block public access to it. Preferably with a Coming Soon page. But I still want to access it "maybe with a login, or any other way" so that I can deploy my codes, continue adding content until I'm ready for public release.


Solution

  • Well, merry Xmas to you too.

    As for your question there are a lot of various solution here. You could do it directly through your HTTP Server, for exemple, tell you server to automaticaly redirect to /coming_soon if a defined HTTP HEADER is not found in the request.

    You could also set a custom cookie value in you browser with a randomized string and check the value in a before_filter (see How to access cookies from ApplicationController (Rails) )

    Or use an authorization gem like cancancan or pundit (I do prefer the latter over the former but it's more a matter of taste) to define your redirection rules (I do think it would be overkill to use these gem only for that behavior though)