pg::error error relations users already exists - ruby-on-rails

I am trying to deploy my app to heroku. Everything works fine until I try to run "heroku run rake db:migrate". Then I get the following error (please open this image in new tab to see better:
I ran rake db:drop, rake db:create, and rake db:migrate locally. Then I pushed it to heroku and tried running "heroku run rake db:migrate" again, but same error. I know this has something to with the schema already having user table, but I don't see it on my files.
Gem file:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.6'
# Use sqlite3 as the database for Active Record
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# for users
gem 'devise', '~> 4.2'
# Use ActiveModel has_secure_password
gem 'bcrypt', git: 'https://github.com/codahale/bcrypt-ruby.git', :require => 'bcrypt'
# Use Unicorn as the app server
# gem 'unicorn'
gem 'tzinfo-data'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
end
group :test do
# for seeing test covarage
gem 'simplecov', :require => false
end
group :development do
# 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'
gem 'sqlite3'
end
# upload files
gem 'carrierwave', '~> 1.0'
# bootstraps
gem 'bootstrap-sass', '~> 3.3.4.1'
# Material Icons
gem 'material_icons'
# Material css
gem 'materialize-sass'
group :production do
gem 'pg', '0.15'
gem 'rails_12factor'
end
Is there something else I have to do or am I missing something?

That means your table "users" already exists on heroku. Do you really want to delete all tables on heroku ? If so, you have you can do
heroku pg:reset DATABASE
https://devcenter.heroku.com/articles/heroku-postgresql#pg-reset
If you only want to make some changes on your tables you should really work with migrations like
add_column :users, :my_attribute, ...
removeColumn :users, :my_attribute_to_remove
PS: To drop, create, migrate the db locally will not have any effects at the db on heroku.

Related

Deploy Rails app to Heroku detect app matching no buildpack

This might be a duplicate however, I could not fix it from those answers so any help will be appreciated.
Error
Failed to detect app matching no buildpack
After creating the Heroku app I set my buildpack (same error comes with heroku/ruby buildpack)
heroku buildpacks:set https://github.com/heroku/heroku-buildpack-ruby.git
Gemfile and Gemfile.lock are in the root folder.
Added ruby version and rails_12factor gem to Gem file.
PostgreSQL set to production.
ruby "2.3.0"
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.4'
group :development, :test do
gem 'sqlite3'
end
group :production, :test do
gem 'pg'
end
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'kaminari'
gem 'soundcloud'
gem 'redis'
gem 'yt', '~> 0.28.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
end
group :development do
# 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
gem 'rails_12factor', group: :production
.gitignore
/.bundle
# Ignore the default SQLite database.
/db/*.sqlite3
/db/*.sqlite3-journal
# Ignore all logfiles and tempfiles.
/log/*
!/log/.keep
/tmp
*.DS_Store

zurb foundation 6 on rails 4 works locally but not on dokku

I have a rails app with foundation 6 gem that renders well locally, but as soon that I push to a dokku server, the layout is not rendered.
On the chrome devlopper console I find the following error:
Uncaught ReferenceError: $ is not defined
My Gemfile
source 'https://rubygems.org'
gem 'rails_12factor', group: :production
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.4'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
#CMS
gem 'comfortable_mexican_sofa', '~> 1.12.0'
gem 'comfy_blog', '~> 1.12.0'
#foundation
gem 'foundation_rails_helper'
gem 'foundation-rails', github: "zurb/foundation-rails"
gem 'foundation-icons-sass-rails'
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
gem 'puma'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
end
group :production do
gem 'pg'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
ruby "2.2.2"
EDIT:
I've realised that locally the application.erb.html is inserted, but on dokku it's not.
Make sure that the assets are precompiled. In the production environment 'rake assets:precompile' has to run through before the rails server is started.

Heroku gemfile error when trying to open and edit my site locally

I am building a site using Heroku using a tutorial in my online class. I keep getting this error when attempting to open it locally:
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).
Here is my gemfile:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.5'
# Use sqlite3 as the database for Active Record
# gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
gem 'sqlite3'
end
group :development do
# 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 'rails_12factor'
gem 'pg'
end
This is the full gem::LoadError:
require path_to_adapter
rescue Gem::LoadError => e
raise Gem::LoadError, "Specified '#{spec[:adapter]}' for database adapter, but the gem is not loaded. Add `gem '#{e.name}'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord)."
rescue LoadError => e
raise LoadError, "Could not load '#{path_to_adapter}'. Make sure that the adapter in config/database.yml is valid. If you use an adapter other than 'mysql', 'mysql2', 'postgresql' or 'sqlite3' add the necessary adapter gem to the Gemfile.", e.backtrace
end
Switch to Postgresql. SQLite is not supported.
Try running bundle install locally and then push to Heroku

Ruby on Rails Gemfile error

I'm new to web developing and doing a self study guide to learn (the odin project). I'm just now getting to the installation of all the different tools I'll need for programming but having an issue. When setting up ruby on rails for Heroku deployment I'm getting a syntax error. I'm following a guide, http://goo.gl/v2LcbU and when I try to do step 7.2 (bundle install --without production) I get a syntax error. I run ruby -c Gemfile and the error says Gemfile:37: syntax error, unexpected keyword_do, expecting $end.
I've tried a few things but I'm confused and not sure what it's trying to say is wrong with line 37. If you look at the guide I linked it had be replace some of the Gemfile and this is what my Gemfile looks like that is causing an error and not allowing me to bundle install --without production.
Gemfile
http://i.imgur.com/IIjvhwM.png
I'm linking an image of it because I'm not sure how to link the file correctly yet, sorry.
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.4'
# Use sqlite3 as the database for Active Record
group :development, :test do
gem 'sqlite3'
end
group :production do
gem 'pg'
gem 'rails_12factor'
end
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.2'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'
group
:doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
This is invalid:
group
:doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
group is a method being called, :doc is an argument and the do...end block is, well, a block. In Ruby, the first method argument needs to immediately follow the method name. Your group should look more like this:
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
you can see other sample by running rails standard command, like this:
rails new apptest
it will automatically generate many files, include Gemfile, at bottom of that, you will see something like this:
group :development, :test do
gem 'byebug'
gem 'web-console', '~> 2.0'
gem 'spring'
gem 'rspec-rails'
gem 'capybara'
end
study from this, add your own gem, enjoy rails:)

Could not find generator 'devise:install' unless using sudo rails generate devise:install

I have a rails app that I am trying to install devise on.
I use the command
rails generate devise:install
but it fails, giving this message:
Could not find generator 'devise:install'. Maybe you meant 'ckeditor:install', 'assets' or 'comment'
however if I use sudo rails generate devise:install it works.
I do not want to generate devise:install as root however.
I have done chmod a+x on the directory.
I also recently changed macbooks and imported my ssh key from the previous macbook, but I added the key with ssh-add. Not sure if this is the problem.
this is my gemfile:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.3'
gem 'thin'
# Use sqlite3 as the database for Active Record
gem 'pg'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
gem 'devise', '3.5.3'
gem 'bootstrap-sass', '~> 3.2.0'
gem 'autoprefixer-rails'
gem 'bootstrap_form'
gem 'kaminari'
gem 'carrierwave'
gem "rmagick", :require => 'RMagick'
gem 'ckeditor'
gem 'acts_as_commentable'
gem 'addressable'
gem 'vimeo'
gem 'underscore-rails'
gem 'gmaps4rails'
gem 'geocoder'
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
gem 'pry'
# 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
gem 'rails_12factor', group: :production
I managed to solve this by deleting my Gemfile.lock, doing bundle install again and then stopping spring with spring stop I could then call the generator without root privileges
It's kind of weird, but I solve the problem restarting my mac

Resources