Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

friendly_routes

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

friendly_routes

  • 0.5.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Friendly Routes

Friendly Routes creates DSL for creating rails routes with human friendly URLs

Gem Version Code Climate Build Status

Usage

How to use my plugin.

Installation

Add this line to your application's Gemfile:

gem 'friendly_routes'

And then execute:

$ bundle

Or install it yourself as:

$ gem install friendly_routes

Examples

Routes.rb example

# config/routes.rb
free = FriendlyRoutes::Params::BooleanParams.new(:free, true: :free, false: :paid)
category = FriendlyRoutes::Params::CollectionParams.new(:category_id, Category, :title)

dummies_route = FriendlyRoutes::Route.new([free, category], controller: :dummies, action: :index)

friendly_url_for dummies_route, :get # '/:free/:category'

second_dummies_route = FriendlyRoutes::Route.new([free, 'categories', category], controller: :dummies, action: :index)

friendly_url_for dummies_route, :get, '/' # '/:free/categories/:category'
friendly_url_for dummies_route, :get, '/hello/' # '/hello/:free/categories/:category'

Controller example

# app/controllers/dummies_controller.rb
class DummiesController < ApplicationController
  before_action :parse_friendly_routes, only: [:index]
  def index
  end
end

Request result example

 Categories:
 <Category id: 1, title: "lorem">
 <Category id: 2, title: "ipsum">


GET "/free/lorem" - { free: true, category_id: 1}
GET "/free/ipsum" - { free: true, category_id: 2}
GET "/paid/lorem" - { free: false, category_id: 1}
GET "/paid/ipsum" - { free: false, category_id: 2}

Contributing

Feel free to contribute into this repository by creating pull requests.

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 25 Oct 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc