Well I do see you’re missing a :through clause on Group:
class Group < ActiveRecord::Base
has_many :users, :through => :memberships
As for the @user.invitations
class User < ActiveRecord::Base
has_many :groups, :through => :memberships
has_many :invitations, :through => :groups (?)
You might be better off defining a method User#invitations and building the relationship programatically.