raw1z / amistad

Adds friendships management into a rails application
http://github.com/raw1z/amistad
MIT License
185 stars 71 forks source link

invited? method on user conflicts with Devise invitable #38

Open guanglunw opened 11 years ago

guanglunw commented 11 years ago

Came across an interesting issue today, where approving friendships was failing, complaining that the number of arguments provided was incorrect.

It seems that amistad and devise invitable conflict by both adding the 'invited?' method to the model. Anyone have any good solutions for this, if I absolutely need both gems?

For now, some monkey-patching is letting me work around the issue, but given that I'm overriding 'approve', it's not exactly robust:

In an initialiser:

module Amistad
  module ActiveRecordFriendModel
    def approve(user)
      friendship = find_any_friendship_with(user)
      return false if friendship.nil? || friendship_invited?(user)
      friendship.update_attribute(:pending, false)
    end
    alias_method :friendship_invited?, :invited?
  end
end

Any suggestions on a better long term solution?

marceloboeira commented 9 years ago

@guanglunw sorry but, what the devise invitable does? you could override with devise_approve ... or something ...