Class: Binda::StructuresController
Instance Method Summary
collapse
#after_sign_in_path_for, #after_sign_out_path_for
Instance Method Details
#create ⇒ Object
22
23
24
25
26
27
28
29
30
|
# File 'app/controllers/binda/structures_controller.rb', line 22
def create
@structure = Structure.new(structure_params)
if @structure.save
redirect_to structure_path( @structure.slug ), notice: "#{ @structure.name.capitalize } structure was successfully created."
else
render :new
end
end
|
#destroy ⇒ Object
44
45
46
47
|
# File 'app/controllers/binda/structures_controller.rb', line 44
def destroy
@structure.destroy
redirect_to structures_url, notice: "#{ @structure.name.capitalize } structure was successfully destroyed."
end
|
#edit ⇒ Object
19
20
|
# File 'app/controllers/binda/structures_controller.rb', line 19
def edit
end
|
#fields_update ⇒ Object
49
50
51
|
# File 'app/controllers/binda/structures_controller.rb', line 49
def fields_update
redirect_to :back, notice: "#{ @structure.name.capitalize } structure was successfully updated."
end
|
#index ⇒ Object
7
8
9
|
# File 'app/controllers/binda/structures_controller.rb', line 7
def index
@structures = Structure.order('position').all.page params[:page]
end
|
#new ⇒ Object
15
16
17
|
# File 'app/controllers/binda/structures_controller.rb', line 15
def new
@structure = Structure.new
end
|
#show ⇒ Object
11
12
13
|
# File 'app/controllers/binda/structures_controller.rb', line 11
def show
redirect_to action: :edit
end
|
#sort ⇒ Object
53
54
55
56
57
58
|
# File 'app/controllers/binda/structures_controller.rb', line 53
def sort
params[:structure].each_with_index do |id, i|
Structure.find( id ).update({ position: i + 1 })
end
render js: "$('##{params[:id]}').sortable('option', 'disabled', false); $('.popup-warning').addClass('popup-warning--hidden'); $('.sortable').removeClass('sortable--disabled')"
end
|
#sort_index ⇒ Object
60
61
62
|
# File 'app/controllers/binda/structures_controller.rb', line 60
def sort_index
@structures = Structure.order('position').all.page params[:page]
end
|
#update ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
|
# File 'app/controllers/binda/structures_controller.rb', line 32
def update
add_new_field_groups
if @structure.update(structure_params)
redirect_to structure_path( @structure.slug ), notice: "#{ @structure.name.capitalize } structure was successfully updated."
else
render :edit
end
end
|