My heroku app's generated files - ruby-on-rails

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.

Related

Rails app on Heroku

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.

ActiveRecord::ConnectionNotEstablished error with ruby on rails

I was trying to learn ruby on rails, so I installed the gem version 4.0.0, when I start my server, and go to localhost:8000, it brings me an error page with error message:
ActiveRecord::ConnectionNotEstablished.
I'm using sqlite3, not MySQL. Any help is appreciated.
edit: i fixed it, had to do with my database.yml
Make sure that you have installed sqlite3 gem: gem install sqlite3 or run bundle install if you have the gem listed on your Gemfile (which you should).
After that run the following commands:
rake db:create # creates the database
rake db:migrate # creates the tables based on your migration files
If the above two works fine, your application should be able to connect to the database. If not you probably have a configuration problem on your config/database.yml.

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

Error on production with devise

git://github.com/plataformatec/devise (at master) is not checked out. Please run `bundle install` (Bundler::GitError)
I see this when i move my site on production. On my localhost it works fine .. whats going on with this devise?
my gem file:
gem 'devise', git: 'git://github.com/plataformatec/devise'
and im using rails 4
What you need to do is run bundle install --deployment. What's happening is that your gems are being installed to the $HOME, and passenger is running as the nobody user, who has a different $HOME. Running --deployment installs the gems local to the application, so Passenger will find it.
This is answer from github and it works.
You are seeing this on production because apparently your production environment does not have the devise gem installed. If you are using heroku, make sure the gem is in the proper gem scope (not :development, :test) so that when the precompiler runs, it is installed. If you are using another environment, you should do exactly what the error says and bundle install it, so that the gem is installed to the production environment.
run bundle install locally. Then push again to production.

ZenTest Error in Rails

I am following the tutorial on railstutoiral.org and encounter the following error: "ZenTest is not part of the bundle. Add it to Gemfile. (Gem::LoadError)." I have ZenTest (4.4.2) installed according to gemlist so what's wrong? Thanks!
Open 'Gemfile' in the root of your rails application, and add a section like this to the bottom:
group :development, :test do
gem 'ZenTest'
end
Then at the command line, type:
bundle install
This command will install the gem and associate it with your application. It might take a few minutes :)
The cause of your problem is that under rails 3, rubygems are managed by a tool called bundler, which manages all the dependencies between your gems and ensures that your application is always started with the right versions of the right gems, even when you move it between servers.
One more thing to note is that if you want to run a command from a gem you've installed using bundler, you need to type 'bundle exec <command>' to ensure the right environment is established to run the command.
Even if you have it installed it isn't getting loaded because it says it isn't in the Gemfile. The Gemfile exists at the root of your project directory.

Resources