# How to correctly load attachment\_fu with an initializer?

**URL:** <https://www.ruby-forum.com/t/how-to-correctly-load-attachment-fu-with-an-initializer/189415>\
**Category:** Rails\
**Created:** [May 31, 2010, 4:56pm UTC](https://www.ruby-forum.com/t/how-to-correctly-load-attachment-fu-with-an-initializer/189415 "2010-05-31T16:56:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rubybox](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/85e7bf/32.png) [@rubybox](https://www.ruby-forum.com/u/rubybox)\
**Post date:** [May 31, 2010, 4:56pm UTC](https://www.ruby-forum.com/t/how-to-correctly-load-attachment-fu-with-an-initializer/189415/1 "2010-05-31T16:56:56Z")

</div>

I seem to be getting 2 errors,  
Attachment\_fu properties are not set  
S3 is complaining ( Im not using it)

S3:  
Processing ApplicationController#index (for 127.0.0.1 at 2010-05-31  
16:49:10) [GET]

NameError (undefined local variable or method `attachment_options' for #<Class:0x105870a40>): searchlogic (2.4.11) lib/searchlogic/named_scopes/conditions.rb: 88:in`method\_missing’  
searchlogic (2.4.11) lib/searchlogic/named\_scopes/  
association\_conditions.rb:19:in `method_missing' searchlogic (2.4.11) lib/searchlogic/named_scopes/ association_ordering.rb:27:in`method\_missing’  
searchlogic (2.4.11) lib/searchlogic/named\_scopes/ordering.rb:30:in  
`method_missing' searchlogic (2.4.11) lib/searchlogic/named_scopes/or_conditions.rb: 28:in`method\_missing’  
app/models/photo.rb:15  
/Library/Ruby/Gems/1.8/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb:  
206:in `const_missing' app/controllers/taggable_sweeper.rb:2 /Library/Ruby/Gems/1.8/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb: 206:in`const\_missing’  
app/controllers/users\_controller.rb:5  
/Library/Ruby/Gems/1.8/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb:  
206:in `const_missing' lib/flash_session_cookie_middleware.rb:14:in`call’  
haml (3.0.4) rails/./lib/sass/plugin/rack.rb:41:in `call' -e:1:in`load’  
-e:1

Rendered rescues/\_trace (50.5ms)  
Rendered rescues/\_request\_and\_response (1.1ms)  
Rendering rescues/layout (internal\_server\_error)

Attachment\_FU error:

Mon May 31 16:51:21 +0200 2010: Read error: #\<NameError: undefined  
local variable or method `attachment_options' for #<Class: 0x105c0c780>> /Library/Ruby/Gems/1.8/gems/searchlogic-2.4.11/lib/searchlogic/ named_scopes/conditions.rb:88:in`method\_missing’  
/Library/Ruby/Gems/1.8/gems/searchlogic-2.4.11/lib/searchlogic/  
named\_scopes/association\_conditions.rb:19:in `method_missing' /Library/Ruby/Gems/1.8/gems/searchlogic-2.4.11/lib/searchlogic/ named_scopes/association_ordering.rb:27:in`method\_missing’  
/Library/Ruby/Gems/1.8/gems/searchlogic-2.4.11/lib/searchlogic/  
named\_scopes/ordering.rb:30:in `method_missing' /Library/Ruby/Gems/1.8/gems/searchlogic-2.4.11/lib/searchlogic/ named_scopes/or_conditions.rb:28:in`method\_missing’  
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active\_record/  
base.rb:1959:in `method_missing' /Users/pascal/Desktop/Actus/apache2/rubydocs/portal/app/models/ photo.rb:15 /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/ dependencies.rb:380:in`load\_without\_new\_constant\_marking’  
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active\_support/  
dependencies.rb:380:in `load_file' /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/ dependencies.rb:521:in`new\_constants\_in’  
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active\_support/  
dependencies.rb:379:in `load_file' /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/ dependencies.rb:259:in`require\_or\_load’  
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active\_support/  
dependencies.rb:425:in `load_missing_constant' /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/ dependencies.rb:80:in`const\_missing\_not\_from\_s3\_library’  
/Library/Ruby/Gems/1.8/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb:  
206:in `const_missing' /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/ dependencies.rb:92:in`const\_missing’  
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active\_support/  
dependencies.rb:98:in `send' /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/ dependencies.rb:98:in`const\_missing’  
/Users/pascal/Desktop/Actus/apache2/rubydocs/portal/app/controllers/  
taggable\_sweeper.rb:2  
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active\_support/  
dependencies.rb:380:in `load_without_new_constant_marking' /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/ dependencies.rb:380:in`load\_file’  
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active\_support/  
dependencies.rb:521:in `new_constants_in' /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/ dependencies.rb:379:in`load\_file’  
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active\_support/  
dependencies.rb:259:in `require_or_load' /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/ dependencies.rb:425:in`load\_missing\_constant’  
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active\_support/  
dependencies.rb:80:in `const_missing_not_from_s3_library' /Library/Ruby/Gems/1.8/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb: 206:in`const\_missing’  
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active\_support/  
dependencies.rb:92:in `const_missing' /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/ inflector.rb:361:in`constantize’  
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active\_support/  
inflector.rb:360:in `each' /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/ inflector.rb:360:in`constantize’  
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active\_support/  
core\_ext/string/inflections.rb:162:in `constantize' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/ observer.rb:38:in`instantiate\_observers’  
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active\_record/  
observer.rb:36:in `each' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/ observer.rb:36:in`instantiate\_observers’  
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action\_controller/  
dispatcher.rb:15:in `define_dispatcher_callbacks' /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/ callbacks.rb:182:in`call’  
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active\_support/  
callbacks.rb:182:in `evaluate_method' /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/ callbacks.rb:166:in`call’  
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active\_support/  
callbacks.rb:90:in `run' /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/ callbacks.rb:90:in`each’  
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active\_support/  
callbacks.rb:90:in `send' /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/ callbacks.rb:90:in`run’  
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active\_support/  
callbacks.rb:276:in `run_callbacks' /Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ dispatcher.rb:51:in`send’  
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action\_controller/  
dispatcher.rb:51:in `run_prepare_callbacks' /Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ dispatcher.rb:56:in`reload\_application’  
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action\_controller/  
reloader.rb:33:in `run' /Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ dispatcher.rb:108:in`call’  
/Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/rails/rack/static.rb:31:in  
`call' /Library/Ruby/Gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:46:in`call’  
/Library/Ruby/Gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in `each' /Library/Ruby/Gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in`call’  
/Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/rails/rack/log\_tailer.rb:  
17:in `call' /Library/Ruby/Gems/1.8/gems/rack-1.0.1/lib/rack/content_length.rb: 13:in`call’  
/Library/Ruby/Gems/1.8/gems/rack-1.0.1/lib/rack/chunked.rb:15:in  
`call' /Library/Ruby/Gems/1.8/gems/rack-1.0.1/lib/rack/handler/mongrel.rb: 64:in`process’  
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/  
gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in `process_client' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in`each’  
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/  
gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `process_client' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in`run’  
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/  
gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `initialize' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in`new’  
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/  
gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in`initialize’  
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/  
gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in`run’  
/Library/Ruby/Gems/1.8/gems/rack-1.0.1/lib/rack/handler/mongrel.rb:  
34:in `run' /Library/Ruby/Gems/1.8/gems/rails-2.3.5/lib/commands/server.rb:111 /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in`gem\_original\_require’  
/Library/Ruby/Site/1.8/rubygems/custom\_require.rb:31:in `require' /Users/pascal/Desktop/Actus/apache2/rubydocs/portal/script/server:3 -e:1:in`load’  
-e:1

Anyone has an working example for an attachment\_fu initializer which  
gets it settings from application.yml?  
I have like this code which is not correct:

def prepare\_options\_for\_attachment\_fu(options)  
attachment\_fu\_options = options.symbolize\_keys.merge(  
{:storage =\> options[‘storage’].to\_sym,  
:max\_size =\> options[‘max\_size’].to\_i.megabytes,  
:processor =\> (options[‘processor’] &&  
options[‘processor’].to\_sym)  
})  
end

Searched google for some tutorial with examples already, how can I  
hook this code, modified so it works into my app so the attachment\_fu  
options are set?

Please help im so stuck on this, kind regards
