Class: LatoSpaces::ApplicationController
- Inherits:
-
Lato::ApplicationController
- Object
- Lato::ApplicationController
- LatoSpaces::ApplicationController
show all
- Includes:
- Groupable
- Defined in:
- app/controllers/lato_spaces/application_controller.rb
Instance Method Summary
collapse
Methods included from Groupable
#authenticate_group, #session_group_create
Instance Method Details
#index ⇒ Object
9
10
11
12
|
# File 'app/controllers/lato_spaces/application_controller.rb', line 9
def index
@memberships = LatoSpaces::Membership.where(lato_user_id: @session.user_id).order(created_at: :desc)
@groups = LatoSpaces::Group.joins(:lato_spaces_memberships).where(lato_spaces_memberships: { lato_user_id: @session.user_id }).order(name: :asc)
end
|
#setgroup ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'app/controllers/lato_spaces/application_controller.rb', line 14
def setgroup
success_redirect_path = LatoSpaces.config.setgroup_redirect_path ? Rails.application.routes.url_helpers.send(LatoSpaces.config.setgroup_redirect_path) : lato_spaces.root_path
respond_to do |format|
if session_group_create(params[:id])
format.html { redirect_to success_redirect_path }
format.json { render json: {} }
else
format.html { redirect_to lato_spaces.root_path, alert: 'Error on changing group.' }
format.json { render json: { error: 'Error on changing group.' }, status: :unprocessable_entity }
end
end
end
|
#setpreferred ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'app/controllers/lato_spaces/application_controller.rb', line 28
def setpreferred
membership = LatoSpaces::Membership.find_by(lato_user_id: @session.user_id, lato_spaces_group_id: params[:id])
respond_to do |format|
if membership&.set_preferred
format.html { redirect_to lato_spaces.root_path }
format.json { render json: {} }
else
format.html { redirect_to lato_spaces.root_path, alert: 'Error on changing preferred group.' }
format.json { render json: { error: 'Error on changing preferred group.' }, status: :unprocessable_entity }
end
end
end
|