I am trying to build an extremely simple AddressBook rails application. However, I am getting this error "Can't mass-assign protected attributes: city_id". How can I fix this? Please feel free to add any comment/suggestion to your answer regarding the rails code below. Thanks.
How I created the project (from scratch):
rails new demo
rails generate model City name:string
rails generate scaffold User name:string city:references
rake db:migrate
db/seeds.db:
City.create(name: "City1")
City.create(name: "City2")
City.create(name: "City3")
rake db:seed
changed this line <%= f.text_field :city %> from app/views/users/_form.html.erb to <%= f.collection_select :city_id, City.all, :id, :name %>
changed user.rb auto-generated line belongs_to :city to has_one :city.
added belongs_to :city to city.rb
P.S: I am using Rails 3.2.3 and Ruby 1.9.3.