Reputation: 1
Hello I am super new to coding & ruby on rails. I am using the Lynda.com "Ruby on rails 3 essential training" I am on section 8 on video called "One-to-many associations"
for those who what tutorial I am referencing.
I keep running into this error
"ActiveRecord::UnknownAttributeError: unknown attribute 'name' for Page"
The command I am running is
first_page = Page.new(:name "First Page", :permalink => "first", :position => 1)
When I run the command without
":name => 'First Page'" as first_page = Page.new(:permalink => "first", :position => 1)
the error goes away.
So that is my confusion is, why giving the object a name causing this error.
Upvotes: 0
Views: 545
Reputation: 11896
You misplaced the :
in setting the name key-value pair:
Instead of:
first_page = Page.new(:name "First Page", :permalink => "first", :position => 1)
Try this (assuming your Ruby version is >= 1.9):
first_page = Page.new(name: "First Page", permalink: "first", position: 1)
Upvotes: 1