Skip to content

Instantly share code, notes, and snippets.

@scambra
Created March 29, 2011 13:04
Show Gist options
  • Save scambra/892311 to your computer and use it in GitHub Desktop.
Save scambra/892311 to your computer and use it in GitHub Desktop.
skip send invitation
class User < ActiveRecord::Base
has_many :group_memberships, :dependent => :destroy
has_many :groups, :through => :group_memberships
attr_accessor :skip_invitation
devise :invitable, :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
protected
def deliver_invitation
super unless skip_invitation
end
end
@group = Group.find_by_name('foo')
@user = User.invite! do |user|
user.skip_invitation = true
@group.members << user
end
GroupMailer.welcome_invitation(@group, @user).deliver
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment