EDIT: This is not a dupe of Can't migrate after scaffold in Hartl's tutorial! I have Arel updated in my Gemfile just in case, but it makes no difference. Also, this is POST-migration, the rake finished just fine. However after the rake, when I try to query the association via the console, that is when I get the error!
I have two models with a simple one-to-many association between them. After adding the second model and raking the db, I opened rails console to test some stuff out, and I get an error every time I try to use the association in a query.
Here are the classes:
class Startup < ActiveRecord::Base
has_many :reqs
end
class Req < ActiveRecord::Base
belongs_to :startup
end
This is the migration for the Reqs table:
class CreateReqs < ActiveRecord::Migration
def change
create_table :reqs do |t|
t.string :title
t.text :desc
t.integer :sort
t.references :startup, index: true
t.timestamps null: false
end
end
end
And here is the simple test I'm trying to test in the console afterwards:
> startup = Startup.first
> startup.reqs ## Generates ArgumentError
> startup.reqs.build ## Generates same error
And here is the beginning of the error:
ArgumentError: wrong number of arguments (1 for 0) from /usr/local/rvm/gems/ruby-2.1.4@rails4/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract_adapter.rb:271:in `initialize' from /usr/local/rvm/gems/ruby-2.1.4@rails4/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract_adapter.rb:271:in
I'm still getting the hang of a lot of the details of RoR, so please hang with me! But from what I thought I knew, this association seems so basic that I have no idea where to start fixing it. Thanks for your help!