I'm working on a Rails 4.2 application on Ubuntu 20.04.
I'm trying to run a rake task using the command below:
rake my-task
But when I run it I get the following error:
NameError: uninitialized constant Rack::LiveReload
Trying to figure out how to resolve it
Here's how I solved it:
The issue had to do with me not specifying the rails environment within which I wanted to run the rake command.
To specify the rails environment, I could use the RAILS_ENV
variable this way:
rake my-task RAILS_ENV=production
OR if my environment is a staging environment:
rake my-task RAILS_ENV=staging
OR you could use the export
command to pass the rails environment:
export RAILS_ENV=production
rake my-task
OR if my environment is a staging environment:
export RAILS_ENV=staging
rake my-task
Reference: websocket-server.rb and scheduler.rb Rack::LiveReload problem
That's all.