I want to git push to my rails app. I can't seem to find any information about it.
I want my rails app to be something like Heroku in a sense I could git push to it, though obviously building is a whole other matter.
How to be able to git push to rails app?
To Push into git you can follow those steps one after another
$ cd my_project
$ git init
$ git add *
$ git commit -m "My initial commit message"
$ git remote add origin git#example.com:my_project.git
$ git push -u origin master
To Push you rails app to heroku you have to follow the following steps
First install gem heroku
$ gem install heroku
then, Login to heroku with your credentials
$ heroku login
then, Add following gem to your Gemfile
group :production do
gem 'pg'
gem 'rails_12factor'
end
Make sure you add a specific ruby version in your Gemfile, ex: ruby '2.1.2'
run $ bundle install
Create heroku app
$ heroku create
Push to heroku
$ git push heroku master
Run migrations
$ heroku run rake db:migrate
that's it :) Here is a great documentation on heroku page, you can see for more details.
Related
I am trying to get into my rails heroku database. Usually I just run:
heroku run rails console
but it's giving me an error: bash: rails: command not found
I have no idea what caused this. Haven't updated my project code.
heroku --version
heroku-toolbelt/3.36.5 (x86_64-darwin15) ruby/2.2.4
heroku-cli/5.6.14-b0cc983 (darwin-amd64) go1.7.4
=== Installed Plugins
heroku-redis#1.2.8
The same happened to me. My problem was that I didn't commit my changes before the first push, so I didn't have the project up. I did:
git add .
git commit -m "first commit"
git push origin heroku
then, before trying rails c, you need to setup the database.
heroku run rake db:migrate
I followed this devcenter.heroku: getting started with rails4
Am new to rails, just going through a tutorial "learn ruby on rails" Have successfully push files/folders to the github repository.
I want to start the server with rails server to view the default home page of the rails app on my browser but I keep getting a NoMethodError.
I am running the command in my project directory "\projects\Rails\blog>",and i have installed all the required gems with the command "bundle install" after specifying Gem version as giving in the tutorial.
I have configured Rails to connect to email server ("Gmail") also. The error is as shown in the image below.
$ rails new learning #creates a new rails project
$ git remote add origin https://github.com/MY_GITHUB_ACCOUNT/learning.git
$ rails generate figaro:install #To create application.yml file to hold ENVs.
$ git push -u origin master
$ git add -A
$ git commit -m "add configuration"
$ git push
$ rails server
I have been working on a rails app and been deploying regularly to heroku using local git depository. I accidentally ran the command:
bundle install --deployment
It seems it downloaded all the gems to the local folder, and now when I want to upload to heroku it is trying to upload many megabytes of gems... How do I undo the command I ran and delete the local gems? How do I prevent bundle install from downloading all gems again?
Wanted to make this an answer because it was jrochkind comment that helped
rm -rf vendor/bundle
The f in -rf ignores the questions asking if you want to really remove this file.
bundle install --no-deployment
The above will disable bundle deployment mode and install needed packages in a non production enviroment
git add .
git commit -m "fixed deployment bundle"
git push heroku master
The above will add all your lock file to git, create a commit with the new update. It will then send your fixed lock file to your master branch to Heroku master branch (It only has a master) along with any other changes you have done.
If you need to send a different branch to Heroku other than your master then instead of git push heroku master run the following code:
git push heroku development:master
The above command will push your development branch to the Heroku master branch. change development to the branch name you want to send to Heroku.
You may try this:
First, remove all your local gems.
rm -r vendor/bundle
Bundle again
bundle install
Run git add --all
Commit and push again to heroku.
Edit Bundler config file at your app root path .bundle/config and remove following line:
BUNDLE_DEPLOYMENT: "true"
Or with oneliner:
sed '/BUNDLE_DEPLOYMENT: "true"/d' .bundle/config
I am trying to git push heroku master my app into production for heroku, and despite the fact that my gemfile looks like this:
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
group :production do
gem 'pg', '0.18.3'
gem 'rails_12factor'
end
and I do :
bundle install --without production
and
git commit -a -m
and finally
git push heroku master
it will reject the transfer saying that pg is not installed in gemfile
Preparing app for Rails asset pipeline
remote: Running: rake assets:precompile
remote: rake aborted!
remote: Gem::LoadError: Specified 'postgresql' for database adapter, but the gem is not loaded. Add `gem 'pg'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).
So, when I do heroku open
I get this
An error occurred in the application and your page could not be served. Please try again in a few moments.
If you are the application owner, check your logs for details.
I dont know if the two errors are related. Heroku did upload my id_rsa.pub key and I did log in via command line through emails and pwd.
So this is where I think the error was, in case someone goes through the same.
1) when I tried to create a ssh key through
cat ~/.ssh/id_rsa.pub
despite the fact that I do have ssh installed by default on my linux it that command did not work at first, so I ended up generating in through a ssh keygene command. I copied it and pasted it (the public one) in my bitbucket ssh keys, but the private one which had been generated did not match with the original one. and the error was due to this mismatch of keys between the private local and public.
I think I also messed up as I was using two different computers and if you do that you have to go on to another schema of different keys for the same account etc.
I restarted from scratch, I deleted my git directory, i deleted my repository at bitbucket and the app at heroku and tried that command again.
For some reason this time the command worked (no, it was not misspelled the first time), so now the synchronization of keys was correct. This time I copied it and pasted it straightway in the ssh keys of bitbucket.
and I went trough the same stuff again like this:
This follows the instructions from the great book by Michael Hartl (The Ruby on Rails Tutorial)
cat ~/.ssh/id_rsa.pub
$ git remote add origin git#bitbucket.org:<username>/hello_app.git
$ git push -u origin --all # pushes up the repo and its refs for the first time
$ git remote add origin git#bitbucket.org:myname/hello_app.git
now for the gemfile
group :production do
gem 'pg', '0.18.3'
gem 'rails_12factor', '0.0.2'
end
$ bundle install --without production
curiously now it did not complain about the pg but about mysql2, so this really does not matter much appearingly
$ git commit -a -m "Update Gemfile.lock for Heroku"
$ heroku version
$ heroku login
$ heroku keys:add
(this time the keys were added or fetched correctly)
$ heroku create
Creating damp-fortress-5769... done, stack is cedar
http://damp-fortress-5769.herokuapp.com/ | git#heroku.com:damp-fortress-5769.git
Git remote heroku added
$ git push heroku master
heroku open
I haven't been able to get Heroku to update my app for some reason. This is the first app I've had problems with this happening. I've tried a couple different methods, but everything I've tried just says in the command "everything is up to date." and when I check heroku, it's just an early version of my app. Any idea why it won't update on Heroku?
Here is what I've tried:
$ bundle exec rake test
$ git add -A
$ git commit -m "..."
$ git checkout master
$ git merge blah
$ bundle exec rake test
$ git push
$ git push heroku
$ heroku run rake db:migrate
and I've also tried this as well:
$ git status
$ git add .
$ git commit -m "..."
$ git push heroku master
$ heroku run db:migrate
Heres the git status:
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
Here's trying to force it
$ git push heroku master --force
Everything up-to-date
Here's with git remote -v
heroku https://git.heroku.com/stupidapp1.git (fetch)
heroku https://git.heroku.com/stupidapp1.git (push)
origin https://github.com/Tyrantt47/stupidapp1.git (fetch)
origin https://github.com/Tyrantt47/stupidapp1.git (push)
Curtis, I feel like this answer could be judged as the antithesis of a good dev, but if you have the code you want to deploy checked into version control and locally, why not just push it to a new Heroku app.
If the name of the repository is any indication of the scale of the application, I would say try it and see the results.
Heroku provides good documentation on migrating a database from one app to another and its add-on services are easy to get setup, if either one of those are a concern.
Food for thought...
I think that the syntax is
git push -f heroku master