Hacker News new | ask | show | jobs
by cookrn 2492 days ago
Sure, I can try! One part of the Rails "magic" that the framework tries to abstract away from an app developer is code loading. So, instead of each file in your app needing to explicitly specify using "require" statements which other files it needs to run, Rails uses Ruby to automatically "require" files for you. This system is dependent on constant names and namespaces matching file names and directory structures. So, a constant (Rails model) like "Sports::Player" used in a controller might be found via lookup automatically in "app/models/sports/player.rb".

A system which does this has been a part of Rails for a _very_ long time, and Zietwerk is an upgrade to it by a longtime Rails contributor that fixes some of the previous downsides and gotchas.

1 comments

Oh, so it's similar to PHP's autoloading based on psr4.