Error executing a Rake Task

Asked

Viewed 155 times

0

I need to perform some custom tasks, but whenever I try, I get the following message: Application has been already initialized. I searched several places, including the OS in English, but without success. It seems to have no definitive solution. My application is working normally with Puma and Nginx. My tasks file is like this:

namespace :access do
    require "modules/blockade.rb"

    desc "Block everybody"
    task block: :environment do
        (...)
    end

    desc "Unblock everybody"
    task unblock: :environment do
        (...)
    end
end

And this file from require, basically like this:

require "#{ENV["PWD"]}/config/environment.rb"

module Blockade
    (...)
end

Can anyone tell me what I’m doing wrong?

1 answer

0

I didn’t get to test but something tells me that line:

require "#{ENV["PWD"]}/config/environment.rb"

is causing your problem. What you need to do exactly to have to give a require on Environment.Rb?

If you just need to load environment variables look for these Gems:

Foreman

Figaro

Browser other questions tagged

You are not signed in. Login or sign up in order to post.