Rails app on Heroku - ruby-on-rails

I'm working on ruby on rails project on hosting machine "nitrous"
I'm trying to push my files on Heroku using command
git push Heroku master</code>
and this is the building log:
note: building log is really big mess all what you need is to read site
Docs to know what they really support before trying to install
something

Heroku does not support sqlite3. It instead uses a PostgreSQL database. I'd recommend following these docs for deploying Rails apps to Heroku:
Rails 4: https://devcenter.heroku.com/articles/getting-started-with-rails4
Rails 5: https://devcenter.heroku.com/articles/getting-started-with-rails5
It's as easy as going to your Gemfile and changing gem 'sqlite3' to gem 'pg'. Be sure to run bundle afterwards.
You'll then need to set up a simple database.yml file, and then rebuild your schema for local development.
Follow the docs and you'll be fine.

in youe gemfile
gem 'pg'
group :development do
gem 'sqlite3'
end
then
bundle install
push Gemfile and Gemfile.lock to git.

Related

Error loading the 'sqlite3' Active Record adapter. Missing a gem it depends on? sqlite3 is not part of the bundle. Add it to your Gemfile for heroku

Hello guys I do not know why but I am getting this strange error on deployment. I have been spending three hours on this but can not get it to work. It has successfully worked before many times and even work once in the three hours deploying a new app. I do not know why I am getting this error on heroku and only heroku.
Gemfile:
Heroku Error:
database.yml:
If anyone have any suggestions, I am all ears!
#petertran98 SQLite is a bad fit for running on Heroku. See the official link by heroku SQLite on Heroku and they recommend using Postgres.
To replace SQLite with Postgres, you need to do the folowwing.
Step - 1: Replace gem 'sqlite3' with gem 'pg' in your Gemfile.
Step - 2: Replace adapter: sqlite3 with adapter: postgresql in your database.yml.
Now try running the deployment. It should do the trick. If you still face some issue then you might need to do 1 of following things on the basis of what error you see.
Either you need to manually add Postgres if that does no gets created automatically with deployment script.
heroku addons:create heroku-postgresql
or if you still see the SQLite error then you might need to delete Gemfile.lock file and run bundle install command again.

how to convert an existing sqlite3 rails project to postgresql rails project

I am a beginner in rails development. till now I was creating small modules using, sqlite3 now I want to convert it to PostgreSQL please help me with step by step procedure.
First you need to install postgres in your OS.
Then replace gem 'sqlite3' to gem 'pg' in Gem file.
Then bundle install command need to run.
Or you can directly create a project through rails new my_app_name --database=postgresql command

trouble generating new rails controller

I am new to ruby on rails development. I am currently having difficulties generating a new rails controller. here is what I input into the terminal:
$ rails generate controller static_pages home help
here is the response I receive:
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/connection_specification.rb:177
:in `rescue in spec': Specified 'sqlite3' for database adapter, but the gem is not loaded.
Add `gem 'sqlite3'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord). (Gem::LoadError)
I am also using Heroku for production so I initially removed sqlite3 because Heroku cant use it by doing:
$ gem uninstall sqlite3
and I removed it from my gemfile and gemfile.lock. Was this a mistake? Any guidance would be much appreciated.
The error is because the config/database.yml file still has sqlite3 as the database adapter for the development database.
If you know which database you want to use for your local development database, set the appropriate database adapter in this file.
Heroku can't use sqlite3; however, you can use sqlite3 for your local development database, and specify postgres or mysql for production database.
Since you are a total beginner, I would recommend following the steps from a detailed tutorial as it is till you become familiar with the various concepts. Michael Hart's Rails Tutorial book is available for free online, and is a very good resource for beginner rails developers.
you cold try to rm Gemfile.lock and bundle install to reinstall your gems
Also make sure that the sqlite3 gem is in the development group
gem 'sqlite3', :group => :development
So that it will not be install on Heroku

My heroku app's generated files

I have a rails app that is deployed to Heroku, I don't know why, but I can't view the application on localhost nor can I access the files created by heroku run rails generate []. The gem in this situation is activeadmin but I would like to know how to get the files that are generated from this command.
The error I get when running rails generate active_admin:install
/Users/michaelscaria/.rvm/gems/ruby-1.9.3-p385/gems/activerecord- 3.2.11/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in `initialize': FATAL: database "crowdery_development" does not exist (PG::Error)
You need to add gem 'pg' in your gemfile.
group :production do
gem "pg"
end
Before bundle install you need to install 'postgresql' using command
sudo apt-get install postgresql
After that do
bundle install --without production
Turns out that I didn't use the same database name that I was had created the app with.

Using Datamapper for Heroku without installing Postgres locally

I want to use datamapper in a rails app i want to deploy on heroku. Therefore i need to add dm-postgres-adapter to my Gemfile. Is there any way to have heroku installing this gem without installing postgreSQL locally?
Limit its context to production using "group".
group :production do
gem "gemname"
end

Resources