Capistrano Deployment Error using Rails version 7 - ruby-on-rails

I have an app built with Ruby on Rails version 7.0.2, and I want to deploy it to a VPS using Capistrano Gem, however when it is about to reach near the end of deployment, I get this error: "ArgumentError: Missing `secret_key_base` for 'production' environment, set this string with `bin/rails credentials:edit"
When I try to run, EDITOR="code --wait" bin/rails credentials:edit and I enter a secret base key, I push it to github repo, then try to deploy, I still get the same error.
How can I solve this if anyone knows the solution?

Related

Capistrano 3 Start Server Error (Rails 4.2)

This is my spec for deployment to my staging:
Rails 4.2.5
Capistrano 3.4.1
Thin 1.7.0
Nginx 1.4.6
Everything works fine, capistrano also able to deploy and run the server
BUT
When I try to access the staging, it's always internal server error and written on log/thin.log on the rails app:
Unexpected error while processing request: Missing 'secret_token' and
'secret_key_base' for 'production' environment, set these values in
'config/secrets.yml'
I also have set the secret_key_base for production environment generated from rake secret RAILS_ENV=production
if I kill the running server process run by capistrano and manually run the server using bundle exec thin -p [MY_PORT] -e production -d start, the error disappears and everything is normal
So,
it passes nginx so the error must be in thin or capistrano
it bugs me everytime I deploy to production then I must kill the
server process and start it manually
my questions are:
why thin server started by capistrano always have error with missing
secret_key_base and secret_token although I already have it on
my secrets.yml?
how to fix it? I'm out of options

Cap production deploy failed error: could not locate gemfile on AWS server

I am deploying a rails app on a AWS ec2 instance through Capistrano.
Cap production deploy:check is successful, but when I am running cap production deploy I get an error.
Can anyone help?
I found the problem. Your Gemfile in the project was named "gemfile" SMALL g
It must be Gemfile.
So the thing run on Mac and Windows. But when you deploy to Linux, it does not see the Gemfile.Please rename the "gemfile" in your project to "Gemfile"
It will work.

Capistrano Nginx Rails, After Rake Db:Migrate "Something went wrong"

I needed to migrate my database, so I made the changes to my local system, pushed them to git, then cap production deploy. Once on the service I went to the current and ran rake db:migrate. Now when I visit my site I receive an error We're sorry, but something went wrong (500). There is no other information and my /opt/nginx/logs/error.log is completely blank. How do I fix this?
I'm using Postgresql, capistrano, rails 3, nginx
If you correctly installed ruby, rails, passenger and nginx, then follow my gist. You should go through the files and change the configuration according to your need. Here, you'll find
Gemfile // required gems for capistrano deployment
Capfile
deploy.rb // change the configuration for your server
production.rb // change the configuration for your server
After fully configured according to the gist, run
cap production deploy:check # it'll tell you what is missing for deploying your application
then, cap production deploy
Always check the production.log file if you facing any problem.

rails console unable to connect to database in staging environment

Using capistrano I'm deploying my Rails 4 app under the environment name "staging". When I ssh onto the server and run rails console, any ActiveRecord queries I do come up with no such table. So I check my Rails.env and sure enough it reads development instead of staging. But even running rails console staging, it does set Rails.env to "staging", but still the ActiveRecord queries say no such table. The app itself is running fine (under Apache and Passenger), but for some reason the rails console is unable to connect to the db.
I've reverted back to when I knew it was working and am still seeing the error, which tells me it is a configuration change i must've made on the server as opposed to a change to the rails app code or capistrano deploy config.
OK, tracked down the answer myself. The RAILS_ENV was originally being set to staging in /etc/environment -- but a while ago this file was removed during some debugging, and not restored.
What does still surprise me is that
rails console staging
does not have the same effect as
export RAILS_ENV=staging
rails console
anyhow, sorted.

"No Heroku apps are configured error" on Heroku Sans

I am configuring heroku_san for deploying Rails to Heroku. When I run any rake task it creates, I keep getting this error:
rake production deploy
No heroku apps are configured. Run:
rails generate heroku:config
I know that there are Heroku apps because I can see them when I run heroku list. What might be happening? Why can't this gem find the Heroku apps?
It looks like the gem was looking for a file called ~/.heroku/credentials. I did not have it. So I created that and added my user email and password separated by a linebreak:
myemail#gmail.com
herokupassword
Worked like a charm.

Resources