Class: Comable::Apartment::UsersController

Inherits:
ApplicationController show all
Defined in:
app/controllers/comable/apartment/users_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_ability, #current_comable_user

Methods included from ApplicationHelper

#admin_roles, #link_to_save, #store_url_options

Instance Method Details

#createObject



22
23
24
25
26
27
28
29
# File 'app/controllers/comable/apartment/users_controller.rb', line 22

def create
  if @user.save
    redirect_to comable_apartment.tenant_user_path(@tenant, @user), notice: Comable.t(:successful)
  else
    flash.now[:alert] = Comable.t(:failure)
    render :new
  end
end

#destroyObject



43
44
45
46
# File 'app/controllers/comable/apartment/users_controller.rb', line 43

def destroy
  @user.destroy
  redirect_to comable_apartment.tenant_users_path(@tenant), notice: Comable.t(:successful)
end

#editObject



31
32
# File 'app/controllers/comable/apartment/users_controller.rb', line 31

def edit
end

#indexObject



11
12
13
# File 'app/controllers/comable/apartment/users_controller.rb', line 11

def index
  @users = @users.with_role(*admin_roles)
end

#newObject



19
20
# File 'app/controllers/comable/apartment/users_controller.rb', line 19

def new
end

#showObject



15
16
17
# File 'app/controllers/comable/apartment/users_controller.rb', line 15

def show
  render :edit
end

#updateObject



34
35
36
37
38
39
40
41
# File 'app/controllers/comable/apartment/users_controller.rb', line 34

def update
  if @user.update_attributes(user_params)
    redirect_to comable_apartment.tenant_user_path(@tenant, @user), notice: Comable.t(:successful)
  else
    flash.now[:alert] = Comable.t(:failure)
    render :edit
  end
end