Class: Admin::BaseController
Constant Summary
Redde::IndexHelper::IGNORED_COLUMNS
Instance Method Summary
collapse
#ancestry_options, #ancestry_tree, #collection, #column_names, #excluded_column_names, #form_column_names, #index_columns, #index_value_for, #list_table, #list_table_cell, #list_table_options, #list_table_row, #model_name, #record, #render_item_column, #show_tree, #sort_priority, #sort_table_options, #title_for, #title_symbol_for
#command_link, #page_header, #page_sidebar, #photoable, #redde_page, #redde_tree, #redde_tree_list, #sidebar_link, #taccusative, #tplural, #tsingular
Instance Method Details
#create ⇒ Object
20
21
22
23
|
# File 'app/controllers/admin/base_controller.rb', line 20
def create
instance_variable_set("@#{record}", model_name.new(params[record.to_sym].permit!))
redirect_or_edit(instance_variable_get("@#{record}"), instance_variable_get("@#{record}").save)
end
|
#destroy ⇒ Object
34
35
36
37
38
|
# File 'app/controllers/admin/base_controller.rb', line 34
def destroy
instance_variable_set("@#{record}", model_name.find(params[:id]))
instance_variable_get("@#{record}").destroy
redirect_to send("admin_#{collection}_path"), notice: "#{model_name.model_name.human} удалена."
end
|
#edit ⇒ Object
25
26
27
|
# File 'app/controllers/admin/base_controller.rb', line 25
def edit
instance_variable_set("@#{record}", model_name.find(params[:id]))
end
|
#index ⇒ Object
10
11
12
13
|
# File 'app/controllers/admin/base_controller.rb', line 10
def index
instance_variable_set("@#{collection}", scope)
return render 'tree' if column_names.include?('ancestry')
end
|
#new ⇒ Object
15
16
17
18
|
# File 'app/controllers/admin/base_controller.rb', line 15
def new
instance_variable_set("@#{record}", model_name.new)
render 'edit'
end
|
#sort ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
|
# File 'app/controllers/admin/base_controller.rb', line 40
def sort
if column_names.include?('ancestry')
model_name.sort(params[:list])
else
params[:pos].each_with_index do |id, idx|
p = model_name.find(id)
p.update(position: idx)
end
end
render nothing: true
end
|
#update ⇒ Object
29
30
31
32
|
# File 'app/controllers/admin/base_controller.rb', line 29
def update
instance_variable_set("@#{record}", model_name.find(params[:id]))
redirect_or_edit(instance_variable_get("@#{record}"), instance_variable_get("@#{record}").update(params[record.to_sym].permit!))
end
|
#welcome ⇒ Object
7
8
|
# File 'app/controllers/admin/base_controller.rb', line 7
def welcome
end
|