Code Monkey home page Code Monkey logo

modular_routes's People

Contributors

vitoravelino avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

modular_routes's Issues

Matching is not working properly

Rails.application.routes.draw do
  modular_routes do
    resources :app, only: %i[index]
    get '/:slug', to: 'tenant_home#index', as: :slug
  end
end

If you set this on config/routes.rb when you go to /app it redirects to /:slug
But if you set this on config/routes.rb works properly

Rails.application.routes.draw do
  get '/app', to: 'app/index#call', as: :app
  get '/:slug', to: 'tenant_home/index#call', as: :slug
end

Define controller method to be called

The idea is to pass an option to modular_routes helper that will overwrite the default controller method name call.

An example of that could be:

# routes.rb

modular_routes controller_method: :execute do
  resources :books, only: :index
end

# controllers/books/index.rb

module Books
  class IndexController 
    def execute
      # ...
    end
  end
end

Support standalones routes

The current support is tied to resource(s). It would be nice to support without that like:

modular_routes do
  get  "/about", to: "about#index"
  post "/setup", to: "setup#create"
end

It would be the same as:

get  "/about", to: "about/index#call"
post "/setup", to: "setup/create#call"

The gain of simplicity is not as big as it is for resources but it would be nice to have the possibility.

Pass api mode through options

Sometimes you might have api endpoints being served within the same traditional web app. Having a way of ignoring :edit and :new would be nice.

# routes/web.rb
modular_routes do
  resources :books
end

# routes/api.rb
modular_routes(api: true) do
  resources :books
end

Support concerns

modular_routes do
  concern :commentable do
    resources :comments
  end

  # as option
  resources :books, concerns: :commentable

  # or inside block

  resources :books do
    concerns :commentable
  end

  # within namespace
  namespace :articles do
    concerns :commentable
  end
end

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.