I am creating this really simple app and i've never had a problem with this but i really dont know what is wrong here. I have an account model that the only attribute is a user_id.
When i create a user everying is ok, but im not being able to create an accout.
User model:
class User < ApplicationRecord
has_many :accounts
end
Account Model:
class Account < ApplicationRecord
belongs_to :user
has_many :credit_cards
end
Schema:
create_table "accounts", force: :cascade do |t|
t.bigint "user_id", null: false
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["user_id"], name: "index_accounts_on_user_id"
end
create_table "users", force: :cascade do |t|
t.string "first_name"
t.string "last_name"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
end
When i do
Account.create(user_id: User.first)
it just doenst create.