I tried but an error happened !
----
NoMethodError in Cajus/authorsController#index
undefined method `after_save' for Author:Class
RAILS_ROOT: /Users/cyrus/jus/jus-revista
Application Trace | Framework Trace | Full Trace
/usr/local/lib/ruby/gems/1.8/gems/couchrest-0.33/lib/couchrest/more/
extended_document.rb:117:in `method_missing'
/Users/cyrus/jus/jus-revista/vendor/plugins/paperclip/lib/paperclip.rb:
221:in `has_attached_file'
/Users/cyrus/jus/jus-revista/app/models/author.rb:5
/Users/cyrus/jus/jus-revista/app/controllers/cajus/
authors_controller.rb:6:in `index'
----
see my model please.
------
class Author < CouchRest::ExtendedDocument
use_database COUCHDB_SERVER.default_database
include Paperclip
has_attached_file :photo,
:styles => {
:normal => "90x120"
},
:storage => :s3,
:s3_credentials => "#{RAILS_ROOT}/config/s3.yml",
:path => ":attachment/:id/:style.:extension",
:bucket => 'development'
property :name
property :surname
property :slug
property :picture_url
property :email
property :gender, :default => 'M'
property :resume
property :articles, :cast_as => ["Article"]
property :site
timestamps!
def initialize(passed_keys={})
super(passed_keys)
self[:title] = self[:attachment_file_name]
self[:content_type] = self[:attachment_content_type]
self[:path] = self.attachment.url
end
# for paperclip
property :attachment_file_name, :type => "String"
property :attachment_content_type, :type => "String"
property :attachment_file_size, :type => "Integer"
property :attachment_updated_at, :type => "Time"
set_callback :before_photo_author_process, :before, :check_before
# save_callback :before, :create_slug
# save_callback :before, :append_articles
# create_callback :before, :separate_name
# save_callback :after, :create_or_save_in_cache
#
view_by :slug
view_by :name
alias full_name name
def to_s
self.id
end
def begin_names
self.name.gsub(/\s*#{self.surname}$/, "")
end
protected
def create_or_save_in_cache
self.add_in_cache(to_s)
end
def separate_name
n = self.name.nil? ? [""] : self.name.strip.split(" ")
self.surname = n.pop if n.size > 1
end
def append_articles
self.articles = articles.map{|a| a.to_s} if self.articles
end
def create_slug
self.slug = name.parameterize.to_s
end
end