Rails 4.0.1 on Heroku, can't create database
I should've read the stack trace more closely. My factories.rb was creating user objects as attributes for other factories. Wrapping them in a block fixed it:
FactoryGirl screws up rake db:migrate process
Creating postgres database on Heroku with Rails 4 error
Minutes after posting this question I figured it out, and I'm hoping this might help someone else out.
The solution was to upgrade from Rails 4.1.8 to Rails 4.2.2.
Then run
heroku run rake db:schema:load
before
heroku run rake db:migrate
For some reason that wouldn't run for my project with Rails 4.1.8. So, after upgrading to Rails 4.2.2, I ran the schema load and migrate commands with no errors.
Rails & Heroku: PG db fails to create database
There are few lessons to be learnt from this problem that I came across, but first let's answer and then explain what was going on.
Short answer:
Despite removing the tests that was considered to cause the rake to break, there were other things left out that needed to be removed and it was causing problems:
1- In the application.rb
this was happening:
config.generators do |g|
g.test_framework :rspec,
fixtures: true,
view_specs: false,
helper_specs: false,
routing_specs: false,
controller_specs: false,
request_specs: false
g.fixture_replacement :factory_girl, dir: "spec/factories"
end
2- In seed.rb
file this was happening:
# user = CreateAdminService.new.call
# puts 'CREATED ADMIN USER: ' << user.email
The lesson:
1- Don't use auto app generators. In my case I was using #RailsComposer.
2- Bower on Rails is a bad decision, it can turn a very simple app to a crazy amazin jungle
Setting up PostgresQL on Heroku Rails 4
Heroku ignores your database.yml
configuration, they generate one when you deploy your application and they also take care of database creation.
All you need to do is heroku run rake db:migrate
and maybe a heroku run rake db:seed
in case you need to seed your database.
Impressionist gem database migration failing on Heroku
Figured it out. My impressionist migration file was somehow missing from my heroku git repository. First I had to generate the impressionist migration again to create the table.
rails g impressionist
migrate it after pushing to heroku:
heroku run rails db:migrate
Related Topics
Why Does Ruby Open-Uri's Open Return a Stringio in My Unit Test, But a Fileio in My Controller
Rake Aborted, Error While Trying to Load the Gem 'Uglifier'
Heroku: Running Imagemagick with Paperclip
How to Create a Ruby Date Object from a String
Convert String to Specific Datetime Format
Ruby: How to Iterate Over an Array of Hashes and Return the Values in a Single String
Creating Signature and Nonce for Oauth (Ruby)
Rails: Money Gem Converts All Amounts to Zero
Guidelines for Where to Put Classes in Rails Apps That Don't Fit Anywhere
How to Call a Super Class Method
Does Dependency Injection Exist in Rails
Instance_Eval Block Not Supplied