DEV Community

Discussion on: Fast way to build CRUD app?

 
spidergears profile image
Deepak Singh

Magic is not bad at all. Love RoR everyday.
It is also super easy to alter these magical pieces to play nice with any of the customisation. And yes, it take time to learn that, figure out these hooks.

Problem I think is discovery, where is this magic happening?

A little example, both Rails and Phoenix have a pluggable architecture but how do you know what stuff is plugged in.

RoR rake middleware is the magic phrase

rake middleware

use Airbrake::UserInformer
use Rack::Sendfile
use ActionDispatch::Static
use Rack::Lock
use #<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x007f9aababbc40>
...
...
use ActionDispatch::ParamsParser
use Remotipart::Middleware
use Rack::Head
use Rack::ConditionalGet
use Rack::ETag
use Warden::Manager

Phoenix, this is explicitly mentioned in the generated routes file.

pipeline :browser do
    plug :accepts, ["html"]
    plug :fetch_session
    ...
    ...
    plug :protect_from_forgery
    plug :put_secure_browser_headers
  end

  pipeline :api do
    plug :accepts, ["json"]
  end

  scope "/", HelloPhoenix do
    pipe_through :browser # Use the default browser stack

    get "/", PageController, :index
    get "/hello", HelloController, :index
    get "/hello/:messenger", HelloController, :show
  end

  # Other scopes may use custom stacks.
  # scope "/api", HelloPhoenix do
  #   pipe_through :api
  # end

Aside: Too much verbosity is an overkill too.