1

I have been trying to deploy my Rails applicaton to Heroku. It uses paperclip and SQLite at my computer and I am trying to use SQLite at my computer and PostgreSQL at Heroku.

Here is my Gemfile:

ruby '1.9.3'
gem 'rails', '3.2.9'

group :production do
  gem "pg"
  gem 'thin'
  gem 'rails_12factor', '0.0.2'
end

group :development, :test do
  gem "sqlite3"
  gem "pg"
end

My config/database.yml:

# SQLite version 3.x
#   gem install sqlite3
#
#   Ensure the SQLite 3 gem is defined in your Gemfile
#   gem 'sqlite3'

development:
  adapter: sqlite3
  database: db/development.sqlite3
  pool: 5
  timeout: 5000

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test: &test
  adapter: sqlite3
  database: db/test.sqlite3
  pool: 5
  timeout: 5000

production:
  adapter: postgresql
  database: tagitpostgree
  pool: 5
  timeout: 5000

cucumber:
  <<: *test

And I have been getting those kind of errors at Heroku. The database is not being created I guess? Any hint?

The errors I am getting are like below:

C:\Sites\tag-it>heroku run rake db:migrate
Running `rake db:migrate` attached to terminal... up, run.3193
Connecting to database specified by DATABASE_URL
rake aborted!
undefined method `has_attached_file' for User(Table doesn't exist):Class
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/dynamic_matchers.rb:50:in `method_missing'
/app/app/models/user.rb:17:in `<class:User>'

My migrations:

ls db/migrate
20121128000354_devise_create_users.rb
20121128000910_rolify_create_roles.rb
20121128000933_add_name_to_users.rb
20130827150824_create_data_files.rb
20130827154510_add_attachment_avatar_to_users.rb
20130827162448_add_avatar_to_users.rb
20130827183819_add_project_to_projects.rb
20130827191647_add_attachment_video_to_projects.rb
20130827195845_create_tags.rb
20130827211446_add_project_id_to_tags.rb
20130827213541_add_user_id_to_tags.rb
20130831173534_create_projectparticipants.rb
20130831184444_add_project_id_to_projectparticipants.rb
20130831184522_add_user_id_to_projectparticipants.rb
20130831190120_adicionando_index.rb
20130908135549_add_college_to_users.rb
20130908143105_add_function_to_users.rb
20130908143303_add_course_to_users.rb
5
  • 1
    In future questions, please take the time to make sure your error codes are formatted and wrapped correctly. When they're not easily read you discourage potential answerers from helping you. Commented Nov 11, 2013 at 2:46
  • Are you sure that you have your migrations in the right order? ALso, looks like you are using something like Paperclip? Is this in your Gemfile? The errormessage is telling you is is trying to create a column on the User table, but the User table doesn't exist.. This can sometimes happen if the migrations are in the wrong order Commented Nov 11, 2013 at 3:33
  • Could you post the files that are in db/migrate/? Are you sure you've added all those files to git and pushed them to your heroku git remote before trying to run heroku run rake db:migrate? A few unrelated issues: heroku by default generates the database.yml from your DATABASE_URL environment variable, so the production config in your database.yml isn't being used unless you're using a custom buildpack or something. Also, if you're not using postgres locally, I don't think you need the pg gem in your development/test groups. Commented Nov 11, 2013 at 4:08
  • As an aside, you should install PostgreSQL locally or create a dev PostgreSQL instance at postgres.heroku.com to avoid future incapability between development and production. Commented Nov 11, 2013 at 4:47
  • Sorry for the formatting, this is my first post here. The first db migration creates a User table. Paperclip is at my Gemfile, I just posted part of it above. How can I know the Database settings at Heroku? Do I create a new DB there? Commented Nov 13, 2013 at 19:38

2 Answers 2

1

You must read error message carefully.

undefined method `has_attached_file' for User(Table doesn't exist):Class

has_attached_file is paperclip method and I can't see paperclip gem in your Gemfile.

Hope this can help you.

1
  • Hi, I have paperclip at the gemfile, I cut off this part on the post. Migrations are in the correct order :( Commented Nov 13, 2013 at 20:10
1

Try running a rake db:setup. You'll also need to include the Postgres login information in your database.yml file.

1
  • I tried adding it manually from the Heroku information I got but no luck. :( rake db:setup that's what I get: d119cakihe65q3 already exists Connecting to database specified by DATABASE_URL rake aborted! undefined method `has_attached_file' for User(Table doesn't exist):Class Commented Nov 13, 2013 at 20:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.