Skip to content

Instantly share code, notes, and snippets.

@patrickberkeley
Created December 7, 2008 02:10
Show Gist options
  • Select an option

  • Save patrickberkeley/33011 to your computer and use it in GitHub Desktop.

Select an option

Save patrickberkeley/33011 to your computer and use it in GitHub Desktop.
using Paperclip for multiple attachments and displaying them using the method described in Advanced Rails Recipe #13
ActiveRecord::UnknownAttributeError in PagesController#create
unknown attribute: file
Application Trace | Framework Trace | Full Trace
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2579:in `attributes='
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2575:in `each'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2575:in `attributes='
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2276:in `initialize'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/reflection.rb:157:in `new'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/reflection.rb:157:in `build_association'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/associations/association_collection.rb:413:in `build_record'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/associations/association_collection.rb:98:in `build'
app/models/page.rb:11:in `new_asset_attributes='
app/models/page.rb:10:in `each'
app/models/page.rb:10:in `new_asset_attributes='
app/controllers/pages_controller.rb:54:in `new'
app/controllers/pages_controller.rb:54:in `create'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2579:in `attributes='
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2575:in `each'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2575:in `attributes='
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2276:in `initialize'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/reflection.rb:157:in `new'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/reflection.rb:157:in `build_association'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/associations/association_collection.rb:413:in `build_record'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/associations/association_collection.rb:98:in `build'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2579:in `send'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2579:in `attributes='
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2575:in `each'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2575:in `attributes='
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2276:in `initialize'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/base.rb:1213:in `send'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/base.rb:1213:in `perform_action_without_filters'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/filters.rb:617:in `call_filters'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/rescue.rb:136:in `perform_action_without_caching'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/caching/sql_cache.rb:13:in `perform_action'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/connection_adapters/abstract/query_cache.rb:48:in `cache'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/query_cache.rb:8:in `cache'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/caching/sql_cache.rb:12:in `perform_action'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/base.rb:533:in `send'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/base.rb:533:in `process_without_filters'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/filters.rb:606:in `process_without_session_management_support'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/session_management.rb:134:in `process'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/base.rb:401:in `process'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/dispatcher.rb:180:in `handle_request'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/dispatcher.rb:107:in `dispatch_unlocked'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/dispatcher.rb:120:in `dispatch'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/dispatcher.rb:119:in `synchronize'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/dispatcher.rb:119:in `dispatch'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/dispatcher.rb:129:in `dispatch_cgi'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/dispatcher.rb:36:in `dispatch'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:76:in `process'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in `synchronize'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in `process'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in `process_client'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `process_client'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `initialize'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `initialize'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:282:in `run'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in `each'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in `run'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:in `run'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/command.rb:212:in `run'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:141:in `load_without_new_constant_marking'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:141:in `load'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:507:in `new_constants_in'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:141:in `load'
/usr/local/lib/ruby/gems/1.8/gems/rails-2.2.0/lib/commands/servers/mongrel.rb:64
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:148:in `require'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:507:in `new_constants_in'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:148:in `require'
/usr/local/lib/ruby/gems/1.8/gems/rails-2.2.0/lib/commands/server.rb:49
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
script/server:3
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2579:in `attributes='
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2575:in `each'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2575:in `attributes='
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2276:in `initialize'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/reflection.rb:157:in `new'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/reflection.rb:157:in `build_association'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/associations/association_collection.rb:413:in `build_record'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/associations/association_collection.rb:98:in `build'
app/models/page.rb:11:in `new_asset_attributes='
app/models/page.rb:10:in `each'
app/models/page.rb:10:in `new_asset_attributes='
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2579:in `send'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2579:in `attributes='
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2575:in `each'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2575:in `attributes='
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2276:in `initialize'
app/controllers/pages_controller.rb:54:in `new'
app/controllers/pages_controller.rb:54:in `create'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/base.rb:1213:in `send'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/base.rb:1213:in `perform_action_without_filters'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/filters.rb:617:in `call_filters'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/rescue.rb:136:in `perform_action_without_caching'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/caching/sql_cache.rb:13:in `perform_action'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/connection_adapters/abstract/query_cache.rb:48:in `cache'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/query_cache.rb:8:in `cache'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/caching/sql_cache.rb:12:in `perform_action'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/base.rb:533:in `send'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/base.rb:533:in `process_without_filters'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/filters.rb:606:in `process_without_session_management_support'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/session_management.rb:134:in `process'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/base.rb:401:in `process'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/dispatcher.rb:180:in `handle_request'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/dispatcher.rb:107:in `dispatch_unlocked'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/dispatcher.rb:120:in `dispatch'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/dispatcher.rb:119:in `synchronize'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/dispatcher.rb:119:in `dispatch'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/dispatcher.rb:129:in `dispatch_cgi'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/dispatcher.rb:36:in `dispatch'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:76:in `process'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in `synchronize'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in `process'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in `process_client'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `process_client'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `initialize'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `initialize'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:282:in `run'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in `each'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in `run'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:in `run'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/command.rb:212:in `run'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:141:in `load_without_new_constant_marking'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:141:in `load'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:507:in `new_constants_in'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:141:in `load'
/usr/local/lib/ruby/gems/1.8/gems/rails-2.2.0/lib/commands/servers/mongrel.rb:64
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:148:in `require'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:507:in `new_constants_in'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:148:in `require'
/usr/local/lib/ruby/gems/1.8/gems/rails-2.2.0/lib/commands/server.rb:49
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
script/server:3
Request
Parameters:
{"commit"=>"Create",
"authenticity_token"=>"7148b67898a9250e22b34b737c428fb6ee59ec9a",
"page"=>{"permalink"=>"a_permalink",
"name"=>"a name",
"new_asset_attributes"=>[{"file"=>#<ActionController::UploadedStringIO:0x212c328>}],
"content"=>"some content"}}
Show session dump
---
:user_id: 1
:return_to:
flash: !map:ActionController::Flash::FlashHash {}
Response
Headers:
{"cookie"=>[],
"Content-Type"=>"",
"Cache-Control"=>"no-cache"}
@ddoolin
Copy link

ddoolin commented Dec 26, 2013

Looks good, but missing the strong parameters in the PageController. Also, link_to_function is being deprecated/removed (or already is in 4.1?), and it should be asset.save(:validate => false).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment