Skip to content

Can't annotate models using memoization. #14

jmcnevin opened this Issue Aug 12, 2010 · 11 comments

10 participants


If you're using memoize inside of an AR model, you will receive the following error during annotation.

Unable to annotate [MODEL].rb: #

ctran commented Feb 9, 2011

Can you provide a sample model?

class Whatever < ActiveRecord::Base
  # attributes don't matter

  # look up rdocs on this
  extend ActiveSupport::Memoizable

  def some_heavy_method
    return 'whatever'
  memoize :some_heavy_method


Looks like you're loading the class twice.


I have the same problem with Rails 3.0.5 & Ruby 1.9.2.
Is this gem still maintained? I hope so, because I love it :)

ctran commented Mar 19, 2011

I'll see what I can do.


Great, thanks!

glennr commented Jul 20, 2011

+1 for this




+1. Still having issues with Rails 3.0.10, Ruby 1.8.7-p302, and annotate 2.4.0.

eagleas commented Sep 16, 2011

+1. Same problem.

turadg commented Sep 16, 2011

Thanks @eagleas. I've merged your fix.

If the problem persists for anyone, please reopen this ticket.

@turadg turadg closed this Sep 16, 2011
adie commented Feb 17, 2012

I still have this problem, installed gem with
gem 'annotate', :git => 'git://'
I've checked that I use the last commit, a43c08f
Rails 3.0.10, ree-1.8.7-2011.12

@alexch alexch added a commit to alexch/annotate_models that referenced this issue Mar 24, 2012
@alexch alexch Merge branch 'ctran'
* ctran: (23 commits)
  Inserting newline requires double-quoted string
  Annotation position defaulted to 'before'. Bugfix: annotate_models.rake uses string instead of symbol.
  include ActiveSupport to finish build #45
  include lib specs
  specify :rubygems source in Gemfile for Travis
  Gemfile for dependencies for Travis CI rake
  make the specs pass (one pending)
  fix column pattern
  Allow task loading from Rakefile for gems (plugin installation already auto-detects). Add skip_on_db_migrate option as well for people that don't want it.
  Fix options parsing to convert strings to proper booleans. Change annotate to use options hash instead of ENV.
  Update README.rdoc to mention Fabrication support
  Add support for Fabrication fabricators
  We had stripped the trailing newlines from our Schema Information section. This small fix supports that case.
  rake task is 'build', not 'gem'
  match indexes and column options too when comparing annotation headers
  Leave magic encoding comment intact
  Fixes issue #14 - RuntimeError: Already memoized
  Count a model as 'annotated' if any of its tests/fixtures are annotated
  Implement FactoryGirl (#47)
  fix gemspec and get rspecs partly working again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.