Class: Alchemy::Admin::ResourcesController
Constant Summary
Alchemy::Admin::ResourceFilter::COMMON_SEARCH_FILTER_EXCLUDES
Instance Method Summary
collapse
controller_path_array, resource_array, resource_model_name, resource_name, resources_name
#contains_relations?, #edit_resource_path, #new_resource_path, #render_attribute, #resource_attribute_field_options, #resource_has_tags, #resource_instance_variable, #resource_model, #resource_path, #resource_relations_names, #resource_scope, #resource_url_proxy, #resource_window_size, #resources_instance_variable, #resources_path
#leave
Methods included from Modules
included, #module_definition_for, register_module
#current_ability
#configuration, #multi_language?, #multi_site?, #prefix_locale?
Instance Method Details
#create ⇒ Object
45
46
47
48
49
50
51
52
53
|
# File 'app/controllers/alchemy/admin/resources_controller.rb', line 45
def create
instance_variable_set(:"@#{resource_name}", resource_handler.model.new(resource_params))
resource_instance_variable.save
render_errors_or_redirect(
resource_instance_variable,
resources_path(resource_instance_variable.class, search_filter_params),
flash_notice_for_resource_action
)
end
|
#destroy ⇒ Object
64
65
66
67
68
69
70
71
|
# File 'app/controllers/alchemy/admin/resources_controller.rb', line 64
def destroy
resource_instance_variable.destroy
if resource_instance_variable.errors.any?
flash[:error] = resource_instance_variable.errors.full_messages.join(", ")
end
flash_notice_for_resource_action
do_redirect_to resource_url_proxy.url_for(search_filter_params.merge(action: "index", only_path: true))
end
|
#edit ⇒ Object
42
43
|
# File 'app/controllers/alchemy/admin/resources_controller.rb', line 42
def edit
end
|
#index ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'app/controllers/alchemy/admin/resources_controller.rb', line 20
def index
items = collection
respond_to do |format|
format.html do
items = items.page(params[:page] || 1).per(items_per_page)
instance_variable_set(:"@#{resources_name}", items)
end
format.csv do
instance_variable_set(:"@#{resources_name}", items)
end
end
end
|
#new ⇒ Object
34
35
36
|
# File 'app/controllers/alchemy/admin/resources_controller.rb', line 34
def new
instance_variable_set(:"@#{resource_name}", resource_handler.model.new)
end
|
#resource_handler ⇒ Object
73
74
75
|
# File 'app/controllers/alchemy/admin/resources_controller.rb', line 73
def resource_handler
@_resource_handler ||= Alchemy::Resource.new(controller_path, alchemy_module)
end
|
#show ⇒ Object
38
39
40
|
# File 'app/controllers/alchemy/admin/resources_controller.rb', line 38
def show
render action: "edit"
end
|
#update ⇒ Object
55
56
57
58
59
60
61
62
|
# File 'app/controllers/alchemy/admin/resources_controller.rb', line 55
def update
resource_instance_variable.update(resource_params)
render_errors_or_redirect(
resource_instance_variable,
resources_path(resource_instance_variable.class, search_filter_params),
flash_notice_for_resource_action
)
end
|