i have two cmd consoles opened in Windows. One is running the "ruby script/server" the other i run a "rake db:migrate" command. But the server console doesn't output the log of the migration? Someone has an idea what's the reason?
You just see this log in your log file. The server log only what happen in this thread, no in other.
Related
I need to run this Rails.logger.info "SMTP_ADDR: #{ENV["SMTP_ADDRESS"].inspect}" in stdout console on my VPS
I'm not sure how to access the stdout console
can someone please advise?
I'm not sure what you mean by stdout, but if you need run this on your VPS environment, rails console probably will help you.
For production environment, run it in the app directory:
RAILS_ENV=production bundle exec rails console
Omit or change rails_env variable for another environment.
I'm unable to execute bundle exec rake because for some reason I can't connect to my database, the error is more than obvious :
rake aborted!
Java::JavaSql::SQLException: ORA-01017: invalid username/password; logon denied
You're seeing Java etc. because I'm using jRuby. So my next move was to start a rails console in test mode which I did with rails console test. Worked just fine, I tried to create a new object just in case and I was able to do it with no issues.
So why is my bundle exec rake failing to connect to the db? And what can I do to fix this? The test db configuration is fine because I can use the test rails console right?
Have no idea what to try next, any hints/tips will be appreciated.
I have an application where I run rake tasks to add data from csv files. I need to test it from the console first. Is there a command in console to revert all the changes as its meant only for testing.
You need to run the console in sandbox mode.
rails c --sandbox
you can run:
bundle exec rails c -s
with -s option all commands are executed in sandbox mode. After exiting the console all commands will be rolled back. (you can use --sandbox or the shorter form -s)
you can start the console in sandbox mode. It will wrap the whole session in a db transaction which will be rollbacked when you close the console.
To start it:
rails console --sandbox
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
I pushed an update to my Rails app production server, and in the update there was a new database migration. I ran rake db:migrate and got the common error seen here. I ran the rake again in bundle exec bash and it was successful. But after restarting my apache server, I'm now getting the 500 Error page. This update worked fine on my localhost, and was mostly this update to the db with supporting changes in the according view and controller/routing.
I don't even know why this error appeared this time, as I have pushed db updates successfully before using only rake. Nonetheless, the rake was successful. The 500 error page only shows on pages that require that specific new ActiveRecord. Any ideas on how to debug?
EDIT: My problem was an extremely simple one. I merely forgot to include the environment with the rake:
bundle exec rake db:migrate RAILS_ENV=production
Unfortunately, it took quite a while to narrow that down, as I couldn't use IRB to check the db entries until I followed these steps.
Did you run rake db:migrate on your server? Also be sure to set the RAILS_ENV flag so your production database is updated:
rake db:migrate RAILS_ENV=production