0.0
No commit activity in last 3 years
No release in over 3 years
A gem to avoid repitition in your rails routes file
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

>= 5.0
 Project Readme

draw_static

Cleaning up your static routes in rails

get 'home', to: 'pages#home'
get 'about', to: 'pages#about'
get 'contact-us', to: 'pages#contact_us'

Familiar?

Add

# Gemfile
gem 'draw_static'

To the Gemfile and then run bundle install, then add

# routes.rb

Rails.application.routes.draw do
  draw_static :pages # Or which controller you are using for static routes
end

This set up will generate the static routes based on the controller actions. In this case we are generating the routes for the PagesController, if you want to do it for your PublicPagesController then you would pass: :public_pages

The controller action has to be the same name as the path. All non-word characters in the controller actions name are replaced by hyphens in the path.

e.g

def about_us
end

Will become

get 'about-us', to: 'pages#about_us'

Multiple controllers

You can specify as many controllers as you like.

# routes.rb

Rails.application.routes.draw do
  draw_static :pages, :public, :sales # Or which controller you are using for static routes
end

Limits

# You can limit the routes that are generated by using except or only

draw_static :pages, only: [:home, :contact]
draw_static :pages, except: [:contact]

# also works for multiple controllers

draw_static :pages, :public, except: [:home, :contact]

# actions called either contact or home will be filtered from all controllers.

Enjoy!

Rails

draw_static is a gem for the rails framework, read more about the rails frame work here https://github.com/rails/rails