Paperclip with MongoMapper in Rails 3 -
I'm trying to implement a paperclip in his first Rails application, and I use Rails 3 and MongoDB with mongomapper To be done. I have followed some things to do all the work followed at Just as the blog post shows, I put the paper clip in the config / initializers directory has, I gem gem is installed, the Gemfile (rails 3 right), I bundler ran in my user group, I added When I load the app, I get the following error, paperclip file looks like this What are some suggestions on what I can do? I have got the right to the steps? undefined method user 'Has_attached_file' to receive: Class
module paperclip module ClassMethods def name has_attached_file, options = {} includes InstanceMethods write_inheritable_attribute (: attachment_definitions, {}) If attachment_definitions.nil? "_ {{}} After _post_process": "_ {{}} _post_process" before "_ {{}} =" [] = {: assumptions => []} = merge (option) after_save : save_attached_files before_destroy: destroyed_attached_files define_callbacks: before_post_process, after_post_process define_callbacks: Define_method to name | * Args | A = attachment_for (name) (args.length> 0)? A.to_s (args.first): An end define_method "# {name} =" do | File | Attachment_for (name) .assign (file) end define_method "# {name}?" For attachment (name). File? End validates_each name, logic => lambda {attachment = attachment_for (name) attachment.send (: flush_errors) until attachment.valid? } End-end module tampering # Handle string ID (Mongo) Def id_partition attachment, style if (id = attachment.instance.id) .is_a? (Int) ( "% 09d"% ID) .scan (/ \ d {3} / (). Id.can (/.) / Id.scan (/. {3} /) first (3) Kjoind ( "/") End end end
MongoMapper 0.11.0, paperclip 2.5.2, and 3.0.4 in the form of rail, all you need is:
# Your model requires 'paperclip' class user MongoMapper :: document contains paperclip :: glue has_attached_file: avatar key: avatar_file_name, st Ing end
You no longer need a paperclip starter.
Comments
Post a Comment