Project

susanin

0.01
Low commit activity in last 3 years
No release in over a year
This gem simplify the route generation which generates via `polymorphic_url` method
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 5.0.0, < 8.0
 Project Readme

Susanin

Extend polymorphic_url to replace simple resource with array of resources.

Installation

Add this line to your application's Gemfile:

gem 'susanin'

And then execute:

$ bundle

Or install it yourself as:

$ gem install susanin

Usage

By default gems do nothing. Include module 'susanin' to the controller.

class ApplicationController < ActionController::Base
  include ::Susanin

  susanin do
    [
      [:owner,              ->(r) { [:admin] }],
      [[:frontend, Link],   ->(r) { [:frontend, r] }],
      [User,                ->(r) { [:owner, r] }],
      [Project,             ->(r) { [:owner, r] }],
      [Link,                ->(r) { [:owner, r] }],
      [Admin,               ->(r) { [r.company, r] }],
      [Photo,               ->(r) { [r.admin.company, r.admin, r] }],
      [Gallery,             ->(r) { [r.company, r] }]
    ]
  end

end

Then you're able to call link_to method wihtout knowlege about the nested resources inside routes.rb. Instead of this:

link_to user.email, [:edit, user.company, user], class: 'button'

You are able to write this:

link_to user.email, [:edit, user], class: 'button'

Contributing

  1. Fork it ( https://github.com/[my-github-username]/susanin/fork )
  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 a new Pull Request