Class: Iugu::InvitationsController

Inherits:
SettingsController
  • Object
show all
Defined in:
app/controllers/iugu/invitations_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/iugu/invitations_controller.rb', line 12

def create
  flash[:group] = :user_invitation
  params[:user_invitation][:roles] = params[:user_invitation][:roles].try(:join, ',')
  params[:user_invitation][:account_id] = params[:account_id]
  params[:user_invitation][:invited_by] = current_user.id
  @user_invitation = UserInvitation.create(params[:user_invitation])
  unless @user_invitation.new_record?
    flash[:group] = :general
    redirect_to (params[:account_id]), :notice => I18n.t("iugu.notices.user_invited")
  else
    @account = Account.find(params[:account_id])
    render :new
  end
end

#editObject

Raises:

  • (ActionController::RoutingError)


27
28
29
30
# File 'app/controllers/iugu/invitations_controller.rb', line 27

def edit
  raise ActionController::RoutingError.new('Not Found') unless @user_invitation = UserInvitation.find_by_invitation_token(params[:invitation_token])
  @inviter = User.find(@user_invitation.invited_by)
end

#newObject



7
8
9
10
# File 'app/controllers/iugu/invitations_controller.rb', line 7

def new
  @user_invitation = UserInvitation.new
  @account = Account.find(params[:account_id])
end

#updateObject



32
33
34
35
36
37
38
39
40
41
42
# File 'app/controllers/iugu/invitations_controller.rb', line 32

def update
  if @user_invitation = UserInvitation.find_by_invitation_token(params[:invitation_token])
    if @user_invitation.accept(current_user)
      redirect_to IuguSDK::app_main_url
    else
      redirect_to root_path, :notice => I18n.t("iugu.notices.you_are_already_member_of_this_account")
    end
  else
    raise ActionController::RoutingError.new('Not Found')
  end
end