Skip to content

Can't annotate models using memoization. #14

Closed
jmcnevin opened this Issue Aug 12, 2010 · 11 comments

10 participants

@jmcnevin

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

Unable to annotate [MODEL].rb: #

@ctran
Owner
ctran commented Feb 9, 2011

Can you provide a sample model?

@leonid-shevtsov
class Whatever < ActiveRecord::Base
  # attributes don't matter

  # look up rdocs on this
  extend ActiveSupport::Memoizable

  def some_heavy_method
    return 'whatever'
  end
  memoize :some_heavy_method

end

Looks like you're loading the class twice.

@thibaudgg

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
Owner
ctran commented Mar 19, 2011

I'll see what I can do.

@thibaudgg

Great, thanks!

@glennr
glennr commented Jul 20, 2011

+1 for this

@agibralter

+1

@CodeGnome

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

@eagleas
eagleas commented Sep 16, 2011

+1. Same problem.

@turadg
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
adie commented Feb 17, 2012

I still have this problem, installed gem with
gem 'annotate', :git => 'git://github.com/ctran/annotate_models.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
  ...

Conflicts:
	Gemfile
	Rakefile
	VERSION.yml
	annotate.gemspec
	lib/tasks/annotate_models.rake
	spec/annotate/annotate_models_spec.rb
	spec/spec_helper.rb
e26663b
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.