I added a field “url” to a table, modified the view to show the new
field. Now I’m getting an error in the code that processes the form in
the view:
copy_from_item = Item.find(params[:id])
@item = Item.new(copy_from_item.attributes)
The second line here gives this error:
undefined method `url=’ for #Item:0x246e3f0
RAILS_ROOT:
/Library/WebServer/Documents/Store/Inventory/public/…/config/…
Application Trace | Framework Trace | Full Trace
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.0/lib/active_record/
base.rb:1494:in method_missing' /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.0/lib/active_record/ base.rb:1337:in
send’
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.0/lib/active_record/
base.rb:1337:in attributes=' /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.0/lib/active_record/ base.rb:1336:in
each’
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.0/lib/active_record/
base.rb:1336:in attributes=' /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.0/lib/active_record/ base.rb:1193:in
initialize_without_callbacks’
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.0/lib/active_record/
callbacks.rb:236:in initialize' #{RAILS_ROOT}/app/controllers/items_controller.rb:121:in
new’
#{RAILS_ROOT}/app/controllers/items_controller.rb:121:in `create’
I thought that Rails magically handled new fields. Not so?
What else do I need to do?