On my server I had console working fine last week. Now when I run
rails console RAILS_ENV=production
I get the following error.
config.eager_load is set to nil. Please update your config/environments/*.rb files accordingly:
* development - set it to false
* test - set it to false (unless you use a tool that preloads your test environment)
* production - set it to true
In my production.rb I have the following line:
config.eager_load = true
rails console in development env does run on my server
The command to start the Rails console in production mode:
rails console production
Related
Below details are in reference of Rails 6.
I have created category controller using scaffold in the test environment. I want to crosscheck all the routes and its URI using rails routes --expanded for test environment.
How can i do that?
As to run that command directly in terminal will give routes of development environment.
I have already checked rails console -e test but its exclusively for irb of test env.
You can use RAILS_ENV=environment before the command like this:
RAILS_ENV=test rails routes --expanded
This will output all routes in your test environment.
During cap <env> deploy I get the following error, but all my environment files are set accordingly. What is the deal?
config.eager_load is set to nil. Please update your config/environments/*.rb files accordingly:
development - set it to false
test - set it to false (unless you use a tool that preloads your test environment)
production - set it to true
UPDATE:
I believe this is because capistrano is not pulling down the latest changes from the branch. Does capistrano cache the branch somewhere? I believe this is the case because the latest release which was 10 minutes ago doesn't include my most recent changes.
So this was happening because the repo directory is kind of like a cache...I guess. I just removed it via rm -rf repo and then re-deployed.
I'm following the instructions here: https://devcenter.heroku.com/articles/redistogo to deploy redis on Heroku. I'm however running into some issues while manually precompiling my assets on localhost using:
RAILS_ENV=production bundle exec rake assets:precompile
before pushing it out to heroku. The ENV["REDISTOGO_URL"] config variable isn't set when I'm doing the production mode precompile on localhost so I get an URI error when URI.parse is called.
How do I get around this error? I don't want to hardcode the URI in my production.rb since Heroku sets this when starting the redis server. I'm quite new to this whole asset pipeline / deployment processes so any tip would be appreciated.
In application.rb, I set the following to prevent initialization prior to Redis starting up:
config.assets.initialize_on_precompile = false
I'm trying to deploy an application to Heroku after upgrading to Rails 3.1 with the asset pipeline. I ran into the common issue mentioned on Heroku's troubleshooting page when receiving the error:
could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port xxxx?
I took the suggestions on the page and added the following to my config/application.rb file (after also trying to add it to the individual [environment].rb files to no effect)
config.assets.initialize_on_precompile = false
I've modified my database.yml file to point my production environment to a non-existant database, but when running the assets:precompile task locally, I get the following:
> RAILS_ENV=production bundle exec rake assets:precompile --trace
** Invoke assets:precompile (first_time)
** Execute assets:precompile
rake aborted!
FATAL: database "my_nonexistant_database" does not exist
Tasks: TOP => environment
(See full trace by running task with --trace)
I'm trying to figure out what part of my application is trying to initialize the database so that I can fix it, but I've run out of ideas for getting more debugging information than this.
Anyone have any tips for either getting more information about where my app is trying to init the DB, or for fixing the underlying problem?
You should try the new labs feature http://devcenter.heroku.com/articles/labs-user-env-compile which will make variables available at slug compile time.
How is the environment set in Rails 3.0?
In Rails 2.x, environment.rb contained a line setting RAILS_ENV to production. It was commented out in the generated file. To force a production environment, uncomment that line.
Rails 3.0 contains no such line in environment.rb, and RAILS_ENV is deprecated. Is there something missing, or is the environment set when the server is started (eg "start Mongrel_rails -e production ..."
I'm trying out Rails 3.0 on my deployment host and getting some odd behavior. Specifically, it seems to be trying to load the :development object from database.yml, and it seems to be ignoring the :groups => :development option in the gemfile. Consequently the app is trying to use Sqlite3 on the deployment server where it is not available.
The replacement is Rails.env
I set the environment in my server config.. thin.yml, mongrel_cluster.yml, or whatever server I am using.
When you are using Cap, how do you call "bundle install"? You should be using the --deployment flag when deploying to prod. It would be helpful to see your deploy.rb file.