How can I clear the cache on Heroku?
I've tried heroku run rails c + Rails.cache.clear and receive the following error
Errno::ENOENT: No such file or directory # dir_initialize - /app/tmp/cache/
I also tried heroku run rake tmp:clear (from this post). The task runs but when I go back into the console and run Rails.cache, nothing has changed.
How can I clear the cache?
Did you try this? (This works with Celadon Cedar with the Heroku Toolbelt package at least)
heroku run --app YOUR_APP_NAME rails runner Rails.cache.clear
Update
If the above does not work, try running:
heroku run rake tmp:create
heroku run rake tmp:clear
Related
I have demo ROR app in Heroku and I would like to reset PG DB everyday via Heroku Scheduler. I have some commands, but I don't know how I can use they in Heroku Scheduler. I just paste this, but it don't work for me.
commands:
heroku restart && heroku pg:reset DATABASE_URL --confirm APP_NAME_ON_HEROKU && heroku run rake db:migrate && heroku run rake db:seed
Could you please tell me, how I should to use this commands?
for me worked it:
rake db:schema:load DISABLE_DATABASE_ENVIRONMENT_CHECK=1 && rake db:seed
UPD:
the commands(heroku run rake db:migrate) that I performed early, working only from the Heroku CLI. For Heroku Scheduler we must use these commands without a keywords heroku run. rake db:reset don't work, disabled on the side Heroku. Also I couldn't use heroku pg:reset DATABASE_URL --confirm APP_NAME_ON_HEROKU.
useful links:
How to reset PG Database on Heroku?
Running Rake Commands
Here is the official documentation link
You can use the following command below.
heroku run rake db:schema:load DISABLE_DATABASE_ENVIRONMENT_CHECK=1 db:seed
I have a ruby on rails app, leveraging Postgres running in heroku. I have a staging environment and a production environment in heroku. I want to run the heroku run rake db:migrate on the production environment however I can find the command to do so, any help would be greatly appreciated
I think you can just set the remote to get it to pick the right environment:
heroku run rake db:migrate --remote production
When I ran heroku run rake db:migrate --remote it gave me three choices (heroku, staging & test) I ran the command: heroku run rake db:migrate --remote heroku and it worked!! (didn't understand that heroku was calling my production environment "heroku" and not production) thanks again for all your help
Once spree(3.1) work on local. Next is to push to heroku.
I am sure have postgresql. But seem I have to manually do setup table using one of similar rails command.
In the document I supposed to run
rails g spree:install --user_class=Spree::User
rails g spree:auth:install
rails g spree_gateway:install
My first question is how to run those command for heroku
My solution is using these commands
heroku run rake spree:install --user_class=Spree::User
heroku run rake railties:install:migrations
heroku run rake db:migrate
heroku run rake db:seed
heroku run rake spree_sample:load
You don't need to run these commands again on heroku.
Just add the files generated by spree to git. Also make sure to add spree migrations to git and then you can just deploy it on heroku.
Followed by
heroku run rake db:migrate
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
I'm trying to run the chapter two demo_app from the Ruby on Rails 3 Tutorial book on Heroku and it is not working. gws-demp-app.heroku.com gives the default Rails page, but gws-demo-app.heroku.com/users gives a web page that says "We're sorry, but something went wrong." On my desktop it works fine. I'm using the tools from RailsInstaller.org.
I had problems with heroku rake db:migrate at the end of the chapter not finding the activerecord-postgresql-adapter so I did install gem pg, bundle install, and updated the Gemfile and repositories. Everything is on github at https://github.com/gwshaw/demo_app.
What looks like the same problem appears at https://stackoverflow.com/questions/7619551/heroku-rake-dbmigrate-success-but-not-showing-in-app
I tried heroku restart recommended there, but that causes: Restarting processes... C:/RailsInstaller/Ruby1.9.2/lib/ruby/1.9.1/net/http.rb:6
44:in `initialize': getaddrinfo: No such host is known. (SocketError)
I tried what is claimed to work, precompiling assets with bundle exec rake assets:precompile, but that generates an error: C:/RailsInstaller/Ruby1.9.2/bin/ruby.exe C:/RailsInstaller/Ruby1.9.2/bin/rake as
sets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
rake aborted!
TypeError: Object doesn't support this property or method
(in C:/Sites/rails_projects/demo_app/app/assets/javascripts/application.js)
I'm new to ruby and rails so I'm at a loss. Any ideas?
Solved below.
Yes , this worked for me too after installing the pg gem, I ran the following:
bundle exec rake assets:precompile
git add .
git commit -am "add a note reflecting changes made"
git push
heroku create
git push heroku master
heroku rake db:migrate
heroku db:push
after invoking these commands, I was able to successfully open the demo_app on heroku.
Thanks for your post — I'm new to Rails, but reading your post helped me with a very similar issue.
Here's what worked for me:
Install pg gem to use postgreSQL on Heroku: (related article)
sudo gem install pg
Install taps gem to allow push of your local database to Heroku: (related article)
gem install taps
then the following sequence…
bundle exec rake assets:precompile
git add .
git commit -am "add a note reflecting changes made"
git push
heroku create
git push heroku master
heroku rake db:migrate
heroku db:push
If you're still having trouble, these articles are helpful too:
Stack Overflow - Heroku command: Heroku Rake db:migrate fails
Heroku - Getting Started with Rails 3.0 on Heroku/Cedar
The problem with bundle exec rake assets:precompile was the key and is solved here RoR Precompiling Assets fail while rake assets:precompile - on basically empty application.js
Oddly, Heroku wouldn't automatically precompile the assets on a git push heroku and thus would not find them. I don't think this little demo_app even uses assets, so that may be why it didn't precompile, but it still could not find applicaiton.css and failed. Once I set config.log_level = :debug in production.rb, I could see the problem in the logs. With the precompile working due to the above fix, everything worked.