I have an issue with running the rails console at heroku (cedar-stack). Each of the following commands heroku run console, heroku run rails console, heroku run bundle exec rails console results in the following error-message:
Running bundle exec rails console attached to terminal... up, run.8155
Abort testing: Your Rails environment is running in production mode!
This error-message is a little bit confused. What kind of test tries heroku to start? I just want to fire up the console, which had worked fine 4 weeks ago.
For Cedar Stack and later:
heroku run rails console --app <app name>
Previous stacks could use this command:
heroku run console --app <app name>
If you have multiple environments (staging / production / etc) you need this command:
heroku run -a app-name console
If you only have a single environment and never setup staging or other environments you can just run:
heroku run console
https://github.com/nemrow/rails_app_cheatsheet/blob/master/heroku.rdoc
For some reason you need to explicitly define the console process in the Procfile:
# Procfile
web: script/rails server -p $PORT
console: script/rails console
This blog post has more details: http://platypus.belighted.com/blog/2013/01/21/ruby-2-rails-4-heroku/
I was with the same problem and I decided to do this and it worked
$ heroku run bash
$ cd bin
~/bin $ ruby rails console
You should just use heroku run console as others have answered.
Heroku only runs in one environment at a time, which is configured by the RAILS_ENV and RACK_ENV environments variables.
When you connect, the console will use the correct environment automatically.
Related
I have web RoR, I ran assets:precomplie, and i got file
**/application-dfaaca6b25e0d101d80f81c5cb194f6d39d331886613c0a392283b01b9911cb0.css**
but my web was loaded another file
**application.self-a429e1a197d1ad3e5a775f50a60fd344db3ba490db151ab8c7494a78cba792a2.css**.
i don't know reason. Anybody, can help me? Thanks a lot
I got the same questions. then finally I find the answer:
when you process assets:precomplie, you must specify the env as you run rails, because in different enviroments, the assets version is not same!
when you run rails in development env as rails s, you should process as rake assets:precomplie or assets:precomplie RAILS_ENV=development
when you run rails in production env as rails s -e p, you should process as rake assets:precomplie RAILS_ENV=production
hope this helps!
Solution:
Deploy your application again
if still not solved
SSH into the system
delete the file your_app/manifest_backup
$ bundle exec rake assets:clear
$ bundle exec rake assets:precompile RAILS_ENV=production
restart the webserver ( for Nginx /etc/init.d/nginx restart or $ sudo service nginx restart )
if still not solved deploy your app again
For more info see my blog
https://cbabhusal.wordpress.com/2015/07/20/ruby-on-rails-production-staging-when-asset-path-is-outdated/
I cant figure how to start Delayed Jobs on a dedicated Ubuntu server.
It works fine on my localhost but when I run on my server
sudo RAILS_ENV=production bin/delayed_job restart
I get
sudo: bin/delayed_job: command not found
On top of that, if I run the "rake jobs:work RAILS_ENV=production" command Im getting the following error:
PG::FeatureNotSupported: ERROR: SELECT FOR UPDATE/SHARE is not allowed in subqueries
Apparently theres an issue with my psql version.
Is there any way I can get the script to work? Any effective Capistrano recipes available? All ive found on the web are old recipes for Rails 3 and older versions of capistrano.
Thanks in advance.
EDIT:
I have already bundled install the daemons gem and generated "delayed_job:active_record" on my local machine, then proceded to cap deploy which bundle installed and migrated in the production server.
The bin/delayed_job file exists in the server yet it fails with command not found.
And add this to config/environment.rb:
ENV['RAILS_ENV'] ||= 'production'
Then at your production server:
RAILS_ENV=production rake db:migrate
RAILS_ENV=test production generate delayed_job:active_record && RAILS_ENV=production rake db:migrate
Now after you do that:
RAILS_ENV=production script/delayed_job start
As for Capistrano error you are facing, please try to add the command like:
run "cd #{current_path}; #{sudo} RACK_ENV=production bundle exec #{current_path}/bin/delayed_job start"
You must run this on target server:
bundle exec rails generate delayed_job
I'm deploying Rails application to server. I can easily accomplish everything if I need only production. But I need staging as well.
I launch my unicorn server with the following command:
bundle exec /home/deployer/apps/myapp/shared/bundle/ruby/2.0.0/bin/unicorn_rails \
-D -c /home/deployer/apps/myapp/shared/config/unicorn.config.rb -E staging
But regardless of my command, the server launches application with production environment.
Is there another place in my application where I should specify environment to be staging?
Thanks!
Set the environment variable RAILS_ENV=staging before you run the command. You can do it on the same line even (in Bash):
$ RAILS_ENV=staging bundle exec unicorn...
You would have to have the environment set up in multiple files such as config/environments/ and config/database.yml.
Folks, I am following Ruby on Rails Tutorial and working on the DemoApp in Chapter 2. My env is :
Win 7
Ruby 1.9.3
Rails 4.0.2
I have deployed the demo app (under directory demo_app) locally and have tested it out locally as well. I did push it to Heroku using
c:\rails_projects\demo_app heroku create --stack cedar
c:\rails_projects\demo_app git push heroku master
the app gets deployed to heroku.
When I run: heroku run rake db:migrate
I get the error:
No app specified. Run this command from an app folder or specify which app to use with --app APP.
I have run it with heroku run rake db:migrate --app demo_app
but get the same error.
Not sure what to do.
Heroku will have given your app a random name when you created the app. Run heroku apps from the terminal to get the name of your app, then heroku run rake db:migrate --app your_app_name.
Assuming the name of your app is robot.
On your terminal, heroku run rake db:migrate --app=robot
Trying to run the Heroku console but I am getting this following:
heroku run console
Running console attached to terminal... up, run.1
sh: console: not found
$ heroku run bash works but I seem to get a (green) bash prompt - "~ $" not a rails console! Can I get into the console from here?
fyi
git push heroku v311
Everything up-to-date
The first error is thrown simply because the console command doesn't exist. I personally have never meet a command called console in my life.
The syntax is heroku run the_command_i_want_to_run. For example: heroku run irb or heroku run bash.
The second error: There's no Rakefile in your project root. Since heroku run rails console say that Rails wasn't found, my guess is that your project wasn't (well) deployed.
Make sure you've done git push heroku.
You may also need to check the logs: heroku logs.
a guess:
heroku run rails console
If you're on the Bamboo stack (older stack than Cedar), try:
heroku run script/rails console
This works for me and is the command recommended in Heroku docs.
I got confused by this too.
It's just
$ heroku run console
Do this
heroku run -a my-app script/rails console
Reference: https://devcenter.heroku.com/articles/console-bamboo