That’s really a good feature, if you do that, we can write Rails command 
instead of Rake task.

BTW. {project_root}/lib/commands is a good place, because it has 
{project_root}/lib/tasks there and do the similar job.

From: <rubyonrails-core@googlegroups.com> on behalf of Prem Sichanugrist 
<sikand...@gmail.com>
Reply-To: "rubyonrails-core@googlegroups.com" 
<rubyonrails-core@googlegroups.com>
Date: Friday, January 24, 2020 at 12:48
To: "rubyonrails-core@googlegroups.com" <rubyonrails-core@googlegroups.com>
Subject: Re: [Rails-core] [Proposal] Add additional in-project directory to 
load custom Rails Command within the app

Yep, as 姜军 said — at the point in time where Rails tries to load all available 
commands (in boot.rb) the {project_root}/lib directory isn't included in 
$LOAD_PATH yet.

I can confirm that after the app boots, the lib folder is indeed in the 
$LOAD_PATH. That definitely means lib/commands and lib/rails_commands are 
indeed the correct place to put the commands.

In that case, do you think it'd be ok for me to submit a patch to add 
{project_root}/lib to $LOAD_PATH before the command lookup happens?

After that, Kasper, I'll dig through the history (Basecamp, GitHub, etc) to see 
where you left them off, figuring out what's missing for it to be a 
full-fledged Rails feature, and give it another shot?

-Prem


On Wed, Jan 15, 2020 at 7:42 AM Xavier Noria 
<f...@hashref.com<mailto:f...@hashref.com>> wrote:
Ah, I see now what is the point, commands are able to boot the application (eg, 
runner), but the lookup happens before.

I would not recommend app for that, because by default any subdirectory of app 
is in the autoload paths and eager loaded if eager loading is enabled.

Xavier

PS: BTW, Zeitwerk has nothing to do with $LOAD_PATH, the variable is modified 
by railties code as part of the boot process.

--
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
rubyonrails-core+unsubscr...@googlegroups.com<mailto:rubyonrails-core+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-core/CAM%3DYcdike7D%2BrMR-tUKvZwU4Op3RGn6sAa%2BaQibic2NxSoru3w%40mail.gmail.com<https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Frubyonrails-core%2FCAM%253DYcdike7D%252BrMR-tUKvZwU4Op3RGn6sAa%252BaQibic2NxSoru3w%2540mail.gmail.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=02%7C01%7C%7Cbb08aedc7d0b4e3cc95d08d7a088b208%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637154381266152254&sdata=ARbZ3n81MReQ6WGMayF3iAV%2BSJRKATlEnj2qvqpQOnQ%3D&reserved=0>.
--
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
rubyonrails-core+unsubscr...@googlegroups.com<mailto:rubyonrails-core+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-core/CAG_6CsPrsaOshfz38-qTMhnY14Lc8doUg0VUP6TOQdWeNmPWHQ%40mail.gmail.com<https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Frubyonrails-core%2FCAG_6CsPrsaOshfz38-qTMhnY14Lc8doUg0VUP6TOQdWeNmPWHQ%2540mail.gmail.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=02%7C01%7C%7Cbb08aedc7d0b4e3cc95d08d7a088b208%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637154381266152254&sdata=opuOnZ0Wteq3AmVkphd4J8rhm2a5jIN2gxRwAFD6XWQ%3D&reserved=0>.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-core/342F5678-A4F1-44AD-8007-B4A1057F8597%40hotmail.com.

Reply via email to