0.0
No commit activity in last 3 years
No release in over 3 years
Easily toggle alternate controllers and routes with peek.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 0
 Project Readme

Peek::AltRoutes

Easily toggle alternate controllers and routes.

screen shot 2016-01-15 at 11 33 56 pm

Things this peek view provides:

  • A ready to go route constraint for switching controllers/views or routes
  • A toggle button to quickly enable and disable the alternate routes

Installation

Add this line to your application's Gemfile:

gem 'peek-alt-routes

And then execute:

$ bundle

Or install it yourself as:

$ gem install peek-alt-routes

Usage

Add the following to your config/initializers/peek.rb:

Peek.into Peek::Views::AltRoutes

You may provide a name option to the Peek view to set the button display text:

Peek.into Peek::Views::AltRoutes, name: 'Site Redesign'

Add the following to your app/assets/javascripts/application.js:

//= require peek/views/alt_routes

Add the following to your app/assets/javascripts/application.css:

/*
 *= require peek/views/alt_routes
 */

Use the peek_alt_routes? route constraint as you see fit. In config/routes.rb:

  # Remember that Rails matches the first route it finds (top to bottom) so
  # be sure to put any constrained routes before the open routes.

  # Route group example:
  constraints peek_alt_routes?: true do
    get '/about', to: 'next_site#about'
    get '/contact', to: 'next_site#contact'
  end
  get '/about', to: 'site#about'
  get '/contact', to: 'site#contact'

  # Single case example:
  get 'new-site-only' to: 'new_site#only', constraints: { peek_alt_routes?: true }

  # DRY routes using routing concerns ( >= Rails 4.0 ) example:
  concern :static_pages do
    get '/about, action: 'about'
    get '/contact, action: 'contact'
  end
  scope controller: 'next_site', constraints: { peek_alt_routes?: true } do
    concerns :static_pages
    get '/help', action: 'help'
  end
  scope controller: 'site' do
    concerns :static_pages
  end

When to use this vs Flipper

  • Flipper is a full featured gem that is supplementary to this gem.
  • Prefer this gem only for cases when a full visual redesign is wanted. This gem only does quick user facing feature toggling better than flipper.
  • Use flipper for multiple or non-visual feature toggles or when advanced roll out procedures are needed.

Notes

  • Be sure to render the Peek bar in your alternate views so it may be disabled.
  • Be sure to implement user security into your alternate controllers. Peek-alt-routes simply sets and checks a cookie for determining which routes to use.
  • The peek_alt_routes? method is available in controllers as well should you need it.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request