scinote-web/app/controllers/users/invitations_controller.rb

31 lines
553 B
Ruby
Raw Normal View History

2016-02-12 23:52:43 +08:00
class Users::InvitationsController < Devise::InvitationsController
def update
@org = Organization.new
@org.name = params[:organization][:name]
super do |user|
if user.errors.empty?
@org.created_by = user
@org.save
UserOrganization.create(
user: user,
organization: @org,
role: 'admin'
)
end
end
end
def accept_resource
resource = super
if not @org.valid?
resource.errors.add(:base, @org.errors.to_a.first)
end
resource
end
end