Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to safely reopen models within social_engine #3

Open
hraynaud opened this issue Feb 11, 2012 · 0 comments
Open

Is it possible to safely reopen models within social_engine #3

hraynaud opened this issue Feb 11, 2012 · 0 comments

Comments

@hraynaud
Copy link

This seems like standard ruby stuff but for something reason I'm getting mixed results when I try to "monkey patch" Comment class. What's weird is that it works perfectly fine for the Friending class. Examples:

require 'friending'
class Friending < ActiveRecord::Base
  def follow
    friendor.follow(friendee)
  end
end

The above works without a hitch. However if I try to reopen the Comment model for example:

require 'comment'
class Comment < ActiveRecord::Base
  include SearchResult
end

I get an endless array of errors starting ith undefined method is_votable. I suspect this has something to do with the initialization and the fact that the commentable, votable, etc. stuff is added via the AR extension initializer and is called before deprecated routes but I don't understand why this is affecting me.

class Engine < Rails::Engine
    initializer 'social_engine.ar_extensions', :before=>"action_controller.deprecated_routes" do |app|
      ActiveRecord::Base.extend SocialEngine::Voteable
      ActiveRecord::Base.extend SocialEngine::Commentable
      ActiveRecord::Base.extend SocialEngine::Rateable
      ActiveRecord::Base.extend SocialEngine::Favoriteable
      ActiveRecord::Base.extend SocialEngine::Reputatable
      ActiveRecord::Base.extend SocialEngine::Friendable
      ActiveRecord::Base.extend SocialEngine::Sociable
      ActiveRecord::Base.extend SocialEngine::SocialUser      
    end

Is there something special I need to do to reopen this class given this init logic

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant