scinote-web/app/controllers/users/invitations_controller.rb
2016-02-12 16:52:43 +01:00

30 lines
553 B
Ruby

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