Deploying ruby on rails(3.1) app to Heroku and their issues

I am working on a rails 3.1 app and lately was trying to depoy the code in Heroku. Heroku has excellent tutorials for the same, but you can encounter some issues which are out of the scope to predict that, for Heroku  or anyone as it lies with your system. Same was the case with my system. I am trying to enlist such issues...don't give up hope I know there are plethora of others..try googling them or adding them here in the comments :)

  1. Fatal error, port 22 can't connect to the mentioned url: The error is caused as port 22 of your machine is blocked. You maybe behind a firewall or using a secure connection (like vpn) to connect to the network. Please disconnect vpn to connect to heroku or check your firewall settings and even if that doesn't work ask the infrastructure team to unblock the port 22. This may appear while pushing your changes to github repository too.
  2. permission-denied-publickey-when-deploying-heroku-code-fatal-the-remote-end:  I found the solution from stack overflow. It is not able to find the keys in heroku, try uploading those to the Heroku site using the following command from the application directory from the command prompt.
    heroku keys:add ~/.ssh/
  3. Assets are not precompiled : Either you can refer to the Heroku site  or execute the steps in sequence.
    (i) Add a production block in the database.yml
    (ii) precompile the assets in your local with the following command RAILS_ENV = production rake assets:precompile
    iii) git add public/assets
    (iv) git commit -m " pre complied assets"
    (v) git push heroku master
  4. [remote rejected] master -> master (pre-receive hook declined) error:  This usually occurs after you  have added a new gem and trying to push the Gemfile without the Gemfile.lock being updated. The best way is to remove the Gemfile.lock,
    (i) rm rf Gemfile.lock from the app dir
    (ii) bundle install (this will create a new gemfile.lock)
    (iii) git add . (iv) git commit -m "bundle" (v) git push heroku master
    Refer to this stack overflow issue for details. 
  5. Unable to install pg(posgre) gem in ubuntu:  To install pg gem in ubuntu, apart from adding the gem in the bundler you need to first install the package for installation of the native extensions and the dependencies for the pg gem.
    (i) From the root directory in ubuntu, install the package with this command
    $ sudo apt-get install libpq-dev
    (ii) Add the pg  gem in your Gemfile.
    (iii) bundle
    (iv) git add .
    (v) git commit -m "added pg gem for heroku deployment"
    (vi) git push heroku master
  6. Sprockets::Helpers::RailsHelper::AssetPaths::AssetNotPrecompiledError: To precompile assets and make them working in production(heroku url), add the assets to precompiled as string in production.rb file.
    (i) config.asset.precompile = %w(styles.css example.js)
    config.asset.precompile = true


Popular posts from this blog

Loved this campaign by Vicks India

Uninitialized constant Win32 (NameError)-cucumber