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:references
bundle exec rails g migration add_expense_picture_id_to_expense_texts expense_picture:references
bundle exec rails g migration add_user_id_to_income_pictures user:references
bundle 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_picture
end
and
class IncomeText < ActiveRecord::Base
belongs_to :income_picture
end
ActiveRecord::Base.connection.schema_search_path
command will help you know the current schema