Rails console database schema checking Rails console database schema checking ruby-on-rails ruby-on-rails

Rails console database schema checking


You can check this in db/schema.rb file. If you aren't sure, you can run bundle exec rake db:schema:dump previously - this rake task recreates schema.rb file from database.

According to your edited question, you should generate the following migrations:

bundle exec rails g migration add_user_id_to_expense_pictures user:referencesbundle exec rails g migration add_expense_picture_id_to_expense_texts expense_picture:referencesbundle exec rails g migration add_user_id_to_income_pictures user:referencesbundle exec rails g migration add_income_picture_id_to_income_texts income_picture:references

and run them with bundle exec rake db:migrate.

also, you have some of your associations set unproperly. It should be:

class ExpenseText < ActiveRecord::Base  belongs_to :expense_pictureend

and

class IncomeText < ActiveRecord::Base  belongs_to :income_pictureend


ActiveRecord::Base.connection.schema_search_path command will help you know the current schema


I think you could visualize Rails schema.rb by some tools listed in this link