Class: Apidae::SelectionsController
Instance Method Summary
collapse
#apidae_user, #check_user_data!, #user_has_data?, #user_is_admin?
Instance Method Details
#create ⇒ Object
26
27
28
29
30
31
32
33
34
|
# File 'app/controllers/apidae/selections_controller.rb', line 26
def create
@selection = Selection.new(selection_params)
if @selection.save
redirect_to @selection, notice: 'Selection was successfully created.'
else
render :new
end
end
|
#destroy ⇒ Object
44
45
46
47
|
# File 'app/controllers/apidae/selections_controller.rb', line 44
def destroy
@selection.destroy
redirect_to selections_url, notice: 'Selection was successfully destroyed.'
end
|
#edit ⇒ Object
23
24
|
# File 'app/controllers/apidae/selections_controller.rb', line 23
def edit
end
|
#index ⇒ Object
7
8
9
10
11
12
13
14
|
# File 'app/controllers/apidae/selections_controller.rb', line 7
def index
if user_is_admin?
@selections = Selection.all
else
projects_ids = Project.where(apidae_id: apidae_user.apidae_projects_ids).map {|p| p.id}
@selections = Selection.where(apidae_project_id: projects_ids)
end
end
|
#new ⇒ Object
19
20
21
|
# File 'app/controllers/apidae/selections_controller.rb', line 19
def new
@selection = Selection.new
end
|
#refresh ⇒ Object
49
50
51
52
53
54
55
56
|
# File 'app/controllers/apidae/selections_controller.rb', line 49
def refresh
referrer = (session.delete(:referrer) || selections_url)
if @selection && @selection.add_or_refresh_objs
redirect_to referrer, notice: "La sélection a bien été mise à jour."
else
redirect_to referrer, alert: "Une erreur s'est produite lors de la mise à jour de la sélection."
end
end
|
#show ⇒ Object
16
17
|
# File 'app/controllers/apidae/selections_controller.rb', line 16
def show
end
|
#update ⇒ Object
36
37
38
39
40
41
42
|
# File 'app/controllers/apidae/selections_controller.rb', line 36
def update
if @selection.update(selection_params)
redirect_to @selection, notice: 'Selection was successfully updated.'
else
render :edit
end
end
|